:root {
  --bg: #edf3ef;
  --paper: #fbfcf8;
  --paper-2: #f3f8f4;
  --ink: #112326;
  --muted: #647276;
  --line: #d7e3dc;
  --line-strong: #aec4ba;
  --accent: #0d766c;
  --accent-strong: #075d56;
  --ok: #177245;
  --bad: #b42318;
  --blue: #275a7a;
  --shadow: 0 8px 24px rgba(17, 35, 38, 0.08);
  --gap: 3px;
  --radius: 10px;
}

body[data-ui-theme="modern"] {
  --bg: #f5f7fa;
  --paper: #ffffff;
  --paper-2: #f5f7fa;
  --ink: #1d2129;
  --muted: #4e5969;
  --line: #e5e6eb;
  --line-strong: #c9cdd4;
  --accent: #1677ff;
  --accent-strong: #0f52ba;
  --ok: #00b42a;
  --bad: #f53f3f;
  --blue: #0f52ba;
  --shadow: 0 8px 24px rgba(15, 82, 186, 0.08);
  --radius: 8px;
}

.public-tongue-body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(180deg, #e8f4fb 0%, #f6fbf8 42%, #ffffff 100%);
  color: #1f2c38;
}
.public-tongue-shell {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 16px 14px calc(24px + env(safe-area-inset-bottom));
  display: grid;
  gap: 12px;
}
.public-tongue-hero {
  padding: 12px 2px 4px;
}
.public-tongue-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.public-tongue-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: #2360d7;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0;
}
.public-tongue-brand img {
  width: 38px;
  height: 30px;
  object-fit: contain;
  display: block;
}
.public-tongue-hero h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
  white-space: nowrap;
}
.public-tongue-hero p {
  margin: 6px 0 0;
  color: #536777;
  line-height: 1.55;
}
.public-tongue-edu-fab {
  position: fixed;
  right: 18px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 20;
  width: 54px;
  height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #0d766c;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(13, 118, 108, 0.25);
  animation: publicTongueEduPulse 1.8s ease-in-out infinite;
}
@keyframes publicTongueEduPulse {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-2px) scale(1.06); }
}
.public-tongue-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(41, 93, 132, 0.14);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(42, 82, 120, 0.08);
  padding: 12px;
}
.public-tongue-form {
  display: grid;
  gap: 10px;
}
.public-tongue-form label {
  display: grid;
  gap: 5px;
  font-size: 13px;
  color: #34495c;
}
.public-tongue-form label span {
  color: #c84a3c;
}
.public-tongue-form input {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cad7e4;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 15px;
  color: #1f2c38;
  background: #fff;
  box-sizing: border-box;
}
.public-tongue-grid {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 10px;
}
.public-tongue-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid #d8e5ee;
  border-radius: 6px;
  background: #f7fbfd;
}
.public-tongue-meta small {
  display: block;
  color: #81909c;
  font-size: 12px;
}
.public-tongue-meta strong {
  display: block;
  max-width: 255px;
  overflow-wrap: anywhere;
  font-size: 12px;
  color: #2b5f7e;
}
.public-tongue-camera {
  display: grid;
  gap: 8px;
}
.public-tongue-camera-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid #d6e2eb;
  background: #15212b;
  aspect-ratio: 3 / 4;
}
.public-tongue-camera-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scaleX(-1);
}
.public-tongue-camera-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.public-tongue-capture-float {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  min-height: 34px;
  padding: 0 13px;
  border-color: rgba(255, 255, 255, 0.65);
  box-shadow: 0 8px 18px rgba(5, 18, 28, 0.22);
}
.public-tongue-guide {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 63%;
  height: 63%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  border: 2px dashed rgba(142, 255, 222, 0.96);
  border-radius: 46% 46% 999px 999px / 36% 36% 999px 999px;
  background: rgba(15, 133, 116, 0.08);
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.12);
}
.public-tongue-file {
  display: flex !important;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid #cfd9e3;
  border-radius: 6px;
  background: #fff;
  color: #2f5f7d !important;
  font-weight: 700;
}
.public-tongue-preview-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid #d6e2eb;
  background: #15212b;
  aspect-ratio: 3 / 4;
}
.public-tongue-preview-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.public-tongue-submit {
  width: 100%;
  min-height: 42px;
}
.public-tongue-result {
  min-height: 74px;
  border: 1px solid #dce5ed;
  border-radius: 6px;
  background: #fbfdff;
  padding: 10px;
  font-size: 13px;
  line-height: 1.58;
  color: #435361;
}
.public-tongue-result[data-tone="ok"] {
  border-color: rgba(34, 128, 93, 0.28);
  background: #f3fbf7;
}
.public-tongue-result[data-tone="bad"] {
  border-color: rgba(190, 77, 64, 0.3);
  background: #fff7f5;
}
.public-tongue-result p {
  margin: 6px 0;
}
.public-tongue-result ul {
  margin: 5px 0 9px;
  padding-left: 18px;
}
.public-tongue-result strong,
.public-tongue-result b {
  color: #20384b;
}

.tongue-edu-body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(180deg, #e8f4fb 0%, #f8fcfa 48%, #ffffff 100%);
  color: #20303d;
}
.tongue-edu-shell {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 16px 14px calc(26px + env(safe-area-inset-bottom));
  display: grid;
  gap: 12px;
}
.tongue-edu-hero {
  padding: 10px 2px 2px;
}
.tongue-edu-hero h1 {
  margin: 2px 0 6px;
  font-size: 27px;
  letter-spacing: 0;
}
.tongue-edu-hero p {
  margin: 0;
  color: #536777;
  line-height: 1.55;
}
.tongue-edu-card {
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(41, 93, 132, 0.14);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(42, 82, 120, 0.08);
  padding: 13px;
}
.tongue-edu-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tongue-edu-player strong {
  display: block;
  color: #20384b;
}
.tongue-edu-player small {
  display: block;
  margin-top: 3px;
  color: #6d7e8b;
}
.tongue-edu-actions {
  display: flex;
  gap: 8px;
}
.tongue-edu-content h2 {
  margin: 16px 0 7px;
  font-size: 17px;
  color: #164f61;
}
.tongue-edu-content h2:first-child {
  margin-top: 0;
}
.tongue-edu-content p,
.tongue-edu-content li {
  color: #3f4f5c;
  font-size: 15px;
  line-height: 1.72;
}
.tongue-edu-content p {
  margin: 0 0 10px;
}
.tongue-edu-content ul {
  margin: 0 0 10px;
  padding-left: 20px;
}
.tongue-edu-source {
  margin: 0 4px;
  color: #7d8a94;
  font-size: 12px;
  line-height: 1.5;
}

.mobile-consult-card {
  margin-top: 8px;
}

.mobile-consult-compact {
  width: min(440px, 34vw);
  min-height: 36px;
  margin-left: auto;
  align-self: center;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(251, 252, 248, 0.92);
}

.mobile-consult-compact-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  flex: 0 0 auto;
  color: var(--accent-strong);
  font-weight: 900;
}

.mobile-consult-compact-head strong {
  white-space: nowrap;
}

.bell-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--accent-strong);
  background: #f7fffb;
  font-weight: 900;
}

.bell-btn.has-pending {
  border-color: #fdba74;
  color: #c2410c;
  background: #fff7ed;
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.14);
}

.bell-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border: 1px solid #fff;
  border-radius: 999px;
  color: #fff;
  background: #dc2626;
  font-size: 12px;
  line-height: 17px;
}

.mobile-consult-list {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
}

.mobile-consult-list.compact {
  flex: 1;
  min-width: 0;
  max-height: 30px;
  gap: 2px;
  overflow: hidden;
}

.mobile-consult-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.mobile-consult-list.compact .mobile-consult-item {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px;
  min-height: 28px;
  padding: 1px 4px;
  border-radius: 8px;
}

.mobile-consult-list.compact .mobile-consult-item > div {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.mobile-consult-list.compact .mobile-consult-item small,
.mobile-consult-list.compact .mobile-consult-item .remote-chip {
  display: none;
}

.mobile-consult-list.compact .mobile-consult-item strong,
.mobile-consult-list.compact .mobile-consult-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline;
  font-size: 16px;
  line-height: 1.05;
}

.mobile-consult-list.compact .mobile-consult-item span {
  flex: 0 0 auto;
  max-width: 86px;
  font-size: 14px;
}

.mobile-consult-list.compact .empty-line {
  margin: 0;
  line-height: 28px;
}

.mobile-consult-item.active {
  border-color: var(--accent);
  background: rgba(15, 133, 116, 0.12);
}

.mobile-consult-item strong,
.mobile-consult-item span,
.mobile-consult-item small {
  display: block;
}

.mobile-chat-panel {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.inline-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mobile-chat-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 7px 9px;
  font-weight: 800;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.mobile-chat-messages {
  height: 150px;
  overflow: auto;
  padding: 10px 12px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  line-height: 1.55;
}

.mobile-chat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 10px;
}

.mobile-chat-item.right {
  align-items: flex-end;
}

.mobile-chat-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.mobile-chat-role {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: #eef3f2;
  color: #476663;
}

.mobile-chat-role.patient {
  background: #eef5f4;
  color: #506d68;
}

.mobile-chat-role.doctor {
  background: rgba(15, 133, 116, 0.16);
  color: #0f6f61;
}

.mobile-chat-role.assistant {
  background: #e4ebff;
  color: #213c8f;
}

.mobile-chat-sender {
  color: var(--ink);
  font-weight: 700;
}

.mobile-chat-bubble {
  width: fit-content;
  max-width: 84%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(8, 45, 40, 0.04);
}

.mobile-chat-bubble.patient {
  border-color: #d7e4e1;
  background: #fff;
}

.mobile-chat-bubble.doctor {
  border-color: rgba(15, 133, 116, 0.35);
  background: rgba(15, 133, 116, 0.10);
}

.mobile-chat-bubble.assistant {
  border-color: #a5b4fc;
  background: #eef2ff;
  color: #172554;
}

.mobile-chat-bubble p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.mobile-chat-bubble small {
  color: var(--muted);
}

#mobile-chat-ai-agent[data-enabled="1"] {
  border-color: rgba(15, 133, 116, 0.4);
  background: rgba(15, 133, 116, 0.08);
  color: #0f6f61;
}

#mobile-chat-ai-agent[data-busy="1"] {
  opacity: 0.72;
}

.mobile-chat-drawer {
  position: fixed;
  left: 6px;
  top: 58px;
  bottom: 6px;
  z-index: 80;
  width: min(420px, calc(100vw - 12px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  margin-top: 0;
  box-shadow: 0 18px 46px rgba(15, 44, 38, 0.24);
  transform: translateX(calc(-100% - 12px));
  transition: transform 0.18s ease;
}

.mobile-chat-drawer.open {
  transform: translateX(0);
}

.mobile-chat-drawer .mobile-chat-messages {
  height: auto;
  max-height: none;
}

.mobile-chat-drawer .mobile-chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  padding: 6px;
  border-top: 1px solid var(--line);
}

.remote-chip {
  width: fit-content;
  margin-top: 2px;
  padding: 1px 6px;
  border: 1px solid #fdba74;
  border-radius: 999px;
  background: #fff7ed;
  color: #c2410c;
  font-style: normal;
  font-weight: 800;
  font-size: 0.82rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.mobile-chat-attachment,
.mobile-message-file {
  display: inline-grid;
  gap: 4px;
  color: var(--accent);
  text-decoration: none;
}

.mobile-chat-attachment {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.mobile-chat-attachment-wrap {
  display: inline-grid;
  gap: 4px;
}

.mobile-chat-attachment img,
.mobile-message-file img {
  max-width: 150px;
  max-height: 120px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.mobile-chat-attachment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.mobile-chat-attachment-actions a {
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 900;
  text-decoration: none;
}

.mobile-attachment-viewer {
  width: min(92vw, 760px);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  background: #f8fffb;
  box-shadow: 0 24px 80px rgba(8, 34, 35, 0.32);
}

.mobile-attachment-viewer::backdrop {
  background: rgba(6, 23, 22, 0.55);
  backdrop-filter: blur(8px);
}

.mobile-attachment-viewer-head,
.mobile-attachment-viewer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
}

.mobile-attachment-viewer-head {
  border-bottom: 1px solid var(--line);
  color: var(--accent-strong);
  font-weight: 900;
}

.mobile-attachment-viewer-body {
  display: grid;
  place-items: center;
  max-height: min(72vh, 720px);
  padding: 14px;
  overflow: auto;
  background: #071b1a;
}

.mobile-attachment-viewer-body img {
  max-width: 100%;
  max-height: 68vh;
  border-radius: 12px;
  object-fit: contain;
}

.mobile-attachment-viewer-actions {
  border-top: 1px solid var(--line);
}

.mobile-attachment-viewer-actions a {
  color: var(--accent-strong);
  font-weight: 900;
  text-decoration: none;
}

.mobile-chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line);
}

.mobile-consult-body {
  margin: 0;
  min-height: 100vh;
  color: #042b2d;
  background:
    radial-gradient(circle at 12% 0%, rgba(55, 172, 150, 0.18), transparent 28rem),
    linear-gradient(155deg, #f8fffb 0%, #eef8f2 58%, #e7f1ec 100%);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

.mobile-consult-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 10px;
  box-sizing: border-box;
}

.mobile-hero,
.mobile-card {
  border: 1px solid rgba(118, 158, 149, 0.42);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 14px 36px rgba(5, 54, 49, 0.08);
}

.mobile-hero {
  position: relative;
  padding: 14px;
}

.mobile-hero-register {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 52px;
  height: 52px;
  min-width: 52px;
  min-height: 52px;
  border: 1px solid rgba(15, 133, 116, 0.35);
  border-radius: 999px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(238, 249, 244, 0.92)),
    radial-gradient(circle at 28% 20%, rgba(255, 255, 255, 0.9), transparent 38%);
  color: #b91c1c;
  font-size: 15px;
  font-weight: 1000;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.9),
    inset 0 -4px 8px rgba(15, 133, 116, 0.10),
    0 8px 18px rgba(5, 54, 49, 0.16);
}

.mobile-hero-register:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 2px 8px rgba(15, 133, 116, 0.16),
    0 4px 10px rgba(5, 54, 49, 0.14);
}

.mobile-hero h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.05;
}

.mobile-hero p:last-child {
  margin: 7px 0 0;
  color: #52706d;
}

.mobile-step-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 8px 0;
  padding: 5px;
  border: 1px solid rgba(118, 158, 149, 0.42);
  border-radius: 15px;
  background: rgba(243, 251, 247, 0.96);
}

.mobile-step-tabs button,
.mobile-auth-switch button,
.mobile-upload-btn {
  min-height: 46px;
  border: 1px solid rgba(15, 133, 116, 0.35);
  border-radius: 14px;
  background: #fff;
  color: #00675e;
  font-weight: 800;
  font-size: 20px;
  padding: 10px 8px;
}

.mobile-step-tabs button {
  flex: 0 0 calc(25% - 4px);
}

.mobile-step-tabs button[data-mobile-tab="shop"] {
  order: 5;
  color: #c9251d;
  border-color: #f0afa5;
  background: #fff6f2;
}

.mobile-step-tabs button[data-mobile-tab="prescriptions"] {
  order: 6;
}

.mobile-step-tabs button[data-mobile-tab="mine"] {
  order: 7;
}

.mobile-step-tabs button.active,
.mobile-auth-switch button.active,
.mobile-doctor-card.active {
  background: #0f8574;
  color: #fff;
}

.mobile-step-tabs button[data-mobile-tab="shop"].active {
  border-color: #c9251d;
  background: #c9251d;
  color: #fff;
}

.mobile-consult-body .btn {
  min-height: 46px;
  border-radius: 14px;
  font-size: 20px;
  font-weight: 900;
}

.mobile-pane {
  display: none;
}

.mobile-pane.active {
  display: block;
}

.mobile-card {
  padding: 10px;
}

.mobile-form {
  display: grid;
  gap: 7px;
}

.mobile-form label {
  display: grid;
  gap: 3px;
  color: #4c6664;
  font-weight: 700;
}

.mobile-form input,
.mobile-form select,
.mobile-form textarea,
.mobile-chat-actions input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(118, 158, 149, 0.58);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  color: #062d30;
  font-size: 16px;
  padding: 10px;
}

.mobile-form textarea {
  min-height: 84px;
  resize: vertical;
}

.mobile-grid-2,
.mobile-code-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.mobile-auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-bottom: 8px;
}

.mobile-register-mode .mobile-auth-switch {
  display: none;
}

.mobile-inline-notice {
  padding: 8px 10px;
  border: 1px solid rgba(15, 133, 116, 0.28);
  border-radius: 12px;
  background: rgba(15, 133, 116, 0.08);
  color: #075d56;
  font-weight: 800;
  line-height: 1.35;
}

.mobile-inline-notice[data-tone="ok"] {
  border-color: rgba(23, 114, 69, 0.35);
  background: rgba(23, 114, 69, 0.10);
  color: #0f653e;
}

.mobile-inline-notice[data-tone="bad"] {
  border-color: rgba(180, 35, 24, 0.32);
  background: rgba(180, 35, 24, 0.10);
  color: #9f2016;
}

.mobile-install-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 18% 18%, rgba(27, 117, 101, 0.34), transparent 32%),
    radial-gradient(circle at 82% 8%, rgba(245, 158, 11, 0.20), transparent 28%),
    rgba(8, 28, 30, 0.58);
  backdrop-filter: blur(12px);
}

.mobile-install-backdrop[hidden] {
  display: none;
}

.mobile-install-card {
  width: min(520px, 100%);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(255, 255, 250, 0.96), rgba(231, 251, 244, 0.96));
  box-shadow: 0 24px 80px rgba(7, 31, 34, 0.28);
}

.mobile-install-card h2,
.mobile-install-card p {
  margin: 0 0 8px;
}

.mobile-install-card h2 {
  color: var(--accent-strong);
  font-size: clamp(22px, 7vw, 31px);
  letter-spacing: -0.03em;
}

.mobile-install-card p {
  color: #335052;
  line-height: 1.55;
}

.mobile-install-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(145deg, #0d766c, #083f3b);
  box-shadow: 0 12px 30px rgba(13, 118, 108, 0.28);
  font-weight: 1000;
  letter-spacing: 0.04em;
}

.mobile-install-permissions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.mobile-install-permissions span {
  padding: 9px;
  border: 1px solid rgba(13, 118, 108, 0.20);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.72);
  color: #35585a;
  font-size: 13px;
}

.mobile-install-permissions strong {
  display: block;
  margin-top: 3px;
  color: var(--accent-strong);
  font-size: 15px;
}

.mobile-install-platform {
  padding: 9px 10px;
  border-radius: 14px;
  background: rgba(245, 158, 11, 0.14);
  color: #7a3d08 !important;
  font-weight: 800;
}

.mobile-install-actions {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 8px;
  margin-top: 12px;
}

.mobile-register-only {
  display: none !important;
}

.mobile-register-mode .mobile-register-only {
  display: grid !important;
}

.mobile-code-login-row {
  display: none;
}

.mobile-register-mode .mobile-code-login-row,
.mobile-code-login-mode .mobile-code-login-row {
  display: grid;
}

.mobile-code-login-mode .mobile-password-field {
  display: none;
}

.mobile-temp-label {
  align-content: start;
}

.mobile-temp-control {
  display: inline-grid;
  grid-template-columns: minmax(90px, 150px) auto;
  align-items: center;
  gap: 8px;
}

.mobile-temp-control > span {
  color: #315955;
  font-size: 20px;
  font-weight: 900;
}

.mobile-patient-card {
  display: grid;
  gap: 2px;
  padding: 10px;
  border: 1px solid rgba(15, 133, 116, 0.28);
  border-radius: 14px;
  background: rgba(15, 133, 116, 0.08);
}

.mobile-patient-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.mobile-patient-card strong {
  font-size: 20px;
}

.mobile-profile-edit-btn {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 14px;
  white-space: nowrap;
}

.mobile-doctor-list {
  display: grid;
  gap: 7px;
  margin-bottom: 8px;
}

.mobile-doctor-card {
  display: grid;
  grid-template-columns: 62px 1fr;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 11px;
  border: 1px solid rgba(118, 158, 149, 0.5);
  border-radius: 14px;
  background: #fff;
  color: #062d30;
}

.mobile-doctor-avatar {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(15, 133, 116, 0.18), rgba(255, 255, 255, 0.8));
  color: #0f8574;
  font-size: 24px;
  font-weight: 1000;
}

.mobile-doctor-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mobile-doctor-info {
  display: grid;
  gap: 3px;
}

.mobile-doctor-card b {
  font-size: 20px;
}

.mobile-mine-card {
  display: grid;
  gap: 6px;
  margin-bottom: 9px;
  padding: 11px;
  border: 1px solid rgba(118, 158, 149, 0.38);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.88);
  color: #183c3b;
}

.mobile-mine-card h3,
.mobile-mine-card p,
.mobile-mine-card ul {
  margin: 0;
}

.mobile-mine-card ul {
  padding-left: 20px;
}

.mobile-mine-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 9px;
}

.mobile-mine-prescription-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.mobile-mine-prescription-row p {
  min-width: 0;
}

.mobile-mine-prescription-row small {
  display: block;
  color: #607572;
  font-size: 0.78em;
  line-height: 1.2;
}

.mobile-chat-list {
  height: 46vh;
  min-height: 260px;
  overflow: auto;
  padding: 9px;
  border: 1px solid rgba(118, 158, 149, 0.48);
  border-radius: 14px;
  background: #fff;
  color: #61716f;
}

.mobile-message {
  width: fit-content;
  max-width: 86%;
  margin-bottom: 7px;
  padding: 8px 10px;
  border: 1px solid rgba(118, 158, 149, 0.42);
  border-radius: 14px;
  background: #fff;
  color: #082d2e;
}

.mobile-message.mine {
  margin-left: auto;
  background: #0f8574;
  color: #fff;
}

.mobile-message.ai-agent {
  border-color: #a5b4fc;
  background: #eef2ff;
  color: #172554;
}

.mobile-message p {
  margin: 4px 0 0;
}

.mobile-attachment-preview {
  margin: 7px 0;
}

.mobile-tongue-card {
  display: grid;
  gap: 8px;
  margin: 9px 0;
  padding: 10px;
  border: 1px solid rgba(15, 133, 116, 0.24);
  border-radius: 14px;
  background: rgba(247, 252, 249, 0.9);
}

.mobile-tongue-card p {
  margin: 0;
  color: #5b706c;
  font-size: 13px;
  line-height: 1.45;
}

.mobile-tongue-capture {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid rgba(15, 133, 116, 0.35);
  border-radius: 14px;
  background: #fff;
  color: #00675e;
  font-size: 18px;
  font-weight: 900;
}

.mobile-tongue-preview-wrap {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid rgba(118, 158, 149, 0.45);
  border-radius: 12px;
  background: #10202a;
}

.mobile-tongue-preview-wrap[hidden] {
  display: none;
}

.mobile-tongue-preview-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mobile-pending-attachment {
  position: relative;
  width: fit-content;
  max-width: 100%;
}

.mobile-attachment-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  min-height: 0;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  background: #dc2626;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
}

.mobile-chat-actions {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px;
  align-items: stretch;
  margin-top: 8px;
}

.mobile-chat-actions textarea {
  width: 100%;
  min-height: 58px;
  max-height: 86px;
  resize: none;
  line-height: 1.35;
}

.mobile-chat-actions .mobile-chat-send-waiting {
  position: relative;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(135deg, #2f756d, #0f8f7d, #2f756d);
  background-size: 220% 100%;
  animation: mobile-waiting-pulse 1.15s ease-in-out infinite;
}

@keyframes mobile-waiting-pulse {
  0% {
    background-position: 0% 50%;
    box-shadow: 0 0 0 rgba(15, 133, 116, 0);
  }
  50% {
    background-position: 100% 50%;
    box-shadow: 0 0 18px rgba(15, 133, 116, 0.36);
  }
  100% {
    background-position: 0% 50%;
    box-shadow: 0 0 0 rgba(15, 133, 116, 0);
  }
}

.mobile-upload-btn {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  text-align: center;
}

.mobile-upload-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.mobile-video-entry {
  width: 100%;
  margin-top: 8px;
}

.mobile-video-entry[hidden] {
  display: none !important;
}

.mobile-video-floater {
  position: fixed;
  z-index: 1200;
  left: 12px;
  top: 12px;
  width: min(50vw, 420px);
  height: 33vh;
  min-width: 230px;
  min-height: 210px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 2px solid rgba(13, 118, 108, 0.62);
  border-radius: 18px;
  background: #082b2a;
  box-shadow: 0 18px 45px rgba(3, 38, 35, 0.26);
  touch-action: none;
}

.mobile-video-floater[hidden] {
  display: none;
}

.mobile-video-floater.fullscreen {
  border-width: 0;
  border-radius: 0;
}

.mobile-video-floater-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 6px 8px;
  color: #fff;
  background: rgba(2, 25, 24, 0.92);
  cursor: move;
  user-select: none;
}

.mobile-video-floater-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-video-floater-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  width: 100%;
}

.mobile-video-floater-actions .btn.mini {
  padding-inline: 9px;
}

.mobile-video-floater-stage {
  position: relative;
  min-height: 0;
  isolation: isolate;
  background: radial-gradient(circle at 30% 20%, rgba(31, 163, 143, 0.34), transparent 42%), #061716;
  cursor: pointer;
}

.mobile-video-floater-stage video[data-mobile-video-doctor],
.mobile-video-floater-stage video[data-mobile-video-local] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mobile-video-floater-stage video[data-mobile-video-doctor] {
  z-index: 2;
  opacity: 0;
  background: #0a1414;
  transition: opacity 0.18s ease;
}

.mobile-video-floater-stage video[data-mobile-video-local] {
  z-index: 1;
  background: #102726;
  filter: saturate(0.92) brightness(0.86);
}

.mobile-video-floater-stage.has-doctor video[data-mobile-video-doctor] {
  opacity: 1;
}

.mobile-video-label {
  position: absolute;
  z-index: 3;
  left: 8px;
  padding: 3px 7px;
  border-radius: 999px;
  color: #eafffb;
  background: rgba(2, 25, 24, 0.7);
  font-size: 12px;
  font-weight: 900;
  pointer-events: none;
}

.mobile-video-label.local {
  bottom: 18px;
}

.mobile-video-label.doctor {
  top: 8px;
  opacity: 0;
}

.mobile-video-floater-stage.has-doctor .mobile-video-label.doctor {
  opacity: 1;
}

.mobile-video-floater-stage.has-doctor .mobile-video-label.local {
  opacity: 0;
}

.mobile-video-floater-stage.has-doctor.swap-videos video[data-mobile-video-local] {
  z-index: 2;
  filter: none;
}

.mobile-video-floater-stage.has-doctor.swap-videos video[data-mobile-video-doctor] {
  inset: auto 10px 10px auto;
  width: 34%;
  height: 28%;
  z-index: 3;
  border: 2px solid rgba(234, 255, 251, 0.86);
  border-radius: 12px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.32);
}

.mobile-video-floater-stage.has-doctor.swap-videos .mobile-video-label.local {
  top: 8px;
  bottom: auto;
  opacity: 1;
}

.mobile-video-floater-stage.has-doctor.swap-videos .mobile-video-label.doctor {
  top: auto;
  right: 14px;
  bottom: calc(28% + 16px);
  left: auto;
  z-index: 4;
}

.mobile-video-floater-stage.has-doctor.swap-videos .mobile-video-meter.local {
  z-index: 4;
  opacity: 1;
}

.mobile-video-floater-stage.has-doctor.swap-videos .mobile-video-meter.doctor {
  right: 14px;
  bottom: 14px;
  left: auto;
  width: 34%;
  z-index: 5;
}

.mobile-video-floater-status {
  padding: 7px 10px;
  color: #e9fffb;
  background: rgba(2, 25, 24, 0.94);
  font-size: 13px;
  font-weight: 800;
}

.mobile-video-floater-status[data-tone="ok"] {
  color: #c7fff3;
}

.mobile-video-floater-status[data-tone="bad"] {
  color: #ffd2d2;
}

.mobile-video-meter {
  position: absolute;
  z-index: 4;
  left: 8px;
  right: 8px;
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.22);
}

.mobile-video-meter.doctor {
  opacity: 0;
  bottom: 8px;
}

.mobile-video-floater-stage.has-doctor .mobile-video-meter.doctor {
  opacity: 1;
}

.mobile-video-meter.local {
  z-index: 2;
  bottom: 8px;
}

.mobile-video-floater-stage.has-doctor .mobile-video-meter.local {
  opacity: 0;
}

.mobile-video-meter i {
  display: block;
  width: 3%;
  height: 100%;
  border-radius: inherit;
  background: #37f4c8;
  transition: width 0.12s ease;
}

.mobile-prescription-box {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid rgba(118, 158, 149, 0.42);
  border-radius: 14px;
  background: #f8fffb;
}

.section-title.compact {
  margin-bottom: 6px;
}

.mobile-prescription-card {
  display: grid;
  gap: 6px;
  color: #365350;
}

.mobile-prescription-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.mobile-prescription-summary span,
.mobile-prescription-tip {
  color: #607572;
}

.mobile-prescription-clinic {
  padding: 2px 8px;
  border: 1px solid rgba(118, 158, 149, 0.42);
  border-radius: 999px;
  background: rgba(239, 248, 245, 0.85);
  color: #2d665d;
}

.mobile-prescription-detail {
  display: grid;
  gap: 5px;
}

.mobile-prescription-detail article {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  padding: 6px 8px;
  border: 1px solid rgba(118, 158, 149, 0.28);
  border-radius: 10px;
  background: #fff;
}

.mobile-prescription-detail article small {
  grid-column: 1 / -1;
  color: #607572;
}

.mobile-prescription-download {
  display: inline-flex;
  justify-content: center;
  text-decoration: none;
}

#mobile-auth-state[data-state="logged-in"] {
  color: #dc2626;
  font-weight: 900;
}

.mobile-address-form {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(118, 158, 149, 0.32);
}

.mobile-date-input-wrap {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.mobile-date-input-wrap input[type="text"] {
  width: 100%;
}

.mobile-date-pick-btn {
  min-height: 42px;
  padding-inline: 12px;
  white-space: nowrap;
}

.mobile-date-native-picker {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.mobile-profile-dialog {
  width: min(92vw, 430px);
  max-height: 86vh;
  padding: 0;
  border: 1px solid rgba(15, 133, 116, 0.26);
  border-radius: 20px;
  background: #f8fffc;
  color: #073c3b;
  box-shadow: 0 22px 60px rgba(5, 58, 55, 0.24);
}

.mobile-profile-dialog::backdrop {
  background: rgba(5, 34, 32, 0.38);
}

.mobile-profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(118, 158, 149, 0.28);
}

.mobile-profile-head h2 {
  margin: 0;
  font-size: 22px;
}

.mobile-profile-form {
  padding: 14px 16px 16px;
}

.mobile-profile-password {
  display: grid;
  gap: 7px;
  margin: 4px 0 2px;
  padding: 10px;
  border: 1px dashed rgba(15, 133, 116, 0.34);
  border-radius: 14px;
  background: rgba(15, 133, 116, 0.05);
}

.mobile-profile-password legend {
  padding: 0 6px;
  color: #245f58;
  font-weight: 900;
}

.mobile-profile-password p {
  margin: 0;
  color: #657675;
  font-size: 13px;
  line-height: 1.35;
}

.mobile-prescription-detail-dialog {
  width: min(94vw, 520px);
}

.mobile-prescription-detail-body {
  display: grid;
  gap: 10px;
  padding: 14px 16px 16px;
}

.mobile-prescription-detail-section {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid rgba(118, 158, 149, 0.3);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
}

.mobile-prescription-detail-section h3,
.mobile-prescription-detail-section p {
  margin: 0;
}

.mobile-prescription-barcode {
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 8px 10px;
  border: 1px solid rgba(45, 102, 93, 0.18);
  border-radius: 12px;
  background: #fff;
}

.mobile-prescription-barcode-svg {
  width: 100%;
  height: 56px;
  fill: #071f1d;
  shape-rendering: crispEdges;
}

.mobile-prescription-barcode small {
  color: #2d665d;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.mobile-prescription-consult-toggle {
  width: 100%;
  justify-content: center;
}

.mobile-prescription-consult-record {
  display: grid;
  gap: 6px;
}

.mobile-prescription-consult-record p {
  white-space: pre-wrap;
  line-height: 1.5;
}

.mobile-recent-prescriptions {
  margin-top: 8px;
}

.mobile-recent-prescription-item {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(118, 158, 149, 0.34);
  border-radius: 12px;
  background: #fff;
}

.mobile-recent-prescription-item p {
  margin: 0;
  color: #365350;
}

.mobile-shop-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  margin-bottom: 8px;
}

.mobile-shop-search input,
#mobile-shop-address {
  width: 100%;
  border: 1px solid rgba(118, 158, 149, 0.58);
  border-radius: 12px;
  background: #fff;
  color: #062d30;
  font-size: 16px;
  padding: 10px;
}

.mobile-shop-categories {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 1px 0 8px;
}

.mobile-shop-categories button {
  flex: 0 0 auto;
  border: 1px solid rgba(15, 133, 116, 0.32);
  border-radius: 999px;
  background: #fff;
  color: #00675e;
  font-weight: 900;
  padding: 8px 12px;
}

.mobile-shop-categories button.active {
  background: #0f8574;
  color: #fff;
}

.mobile-shop-list {
  display: grid;
  gap: 7px;
}

.mobile-shop-item {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(118, 158, 149, 0.35);
  border-radius: 14px;
  background: #fff;
}

.mobile-shop-resume {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border: 1px solid #f1c96f;
  border-radius: 14px;
  background: #fff8df;
  color: #0b4c47;
}

.mobile-shop-resume strong,
.mobile-shop-resume span {
  display: block;
  line-height: 1.25;
}

.mobile-shop-resume span {
  margin-top: 3px;
  color: #9a5b00;
  font-size: 13px;
}

.mobile-shop-thumb,
.mobile-shop-detail-thumb {
  display: grid;
  place-items: center;
  border: 1px solid rgba(15, 133, 116, 0.28);
  border-radius: 14px;
  background: linear-gradient(135deg, #e7fbf3, #d7ecff);
  color: #00675e;
  font-weight: 1000;
}

.mobile-shop-thumb {
  width: 62px;
  height: 62px;
}

.mobile-shop-thumb.small {
  width: 48px;
  height: 48px;
}

.mobile-shop-info {
  min-width: 0;
}

.mobile-shop-name {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #062d30;
  text-align: left;
  font-size: 17px;
  font-weight: 1000;
}

.mobile-shop-name small,
.mobile-shop-info p,
.mobile-shop-order-row p {
  margin: 0;
  color: #607572;
  font-size: 13px;
}

.mobile-shop-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.mobile-shop-meta b {
  color: #d9431f;
  font-size: 18px;
}

.mobile-shop-meta span {
  color: #607572;
  font-size: 13px;
}

.mobile-shop-more {
  width: 100%;
  margin-top: 8px;
}

.mobile-shop-sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: end center;
  background: rgba(0, 0, 0, 0.34);
}

.mobile-shop-sheet[hidden] {
  display: none;
}

.mobile-shop-sheet-card {
  position: relative;
  width: min(100%, 520px);
  max-height: 88vh;
  overflow: auto;
  padding: 14px;
  border-radius: 22px 22px 0 0;
  background: #fff;
  box-shadow: 0 -16px 44px rgba(6, 45, 48, 0.2);
}

.mobile-sheet-close {
  position: absolute;
  top: 10px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(118, 158, 149, 0.38);
  border-radius: 50%;
  background: #fff;
  color: #365350;
  font-size: 22px;
  font-weight: 900;
}

.mobile-shop-detail-hero {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  align-items: center;
  padding-right: 34px;
}

.mobile-shop-detail-thumb {
  width: 112px;
  height: 96px;
  font-size: 28px;
}

.mobile-shop-detail-hero h2 {
  margin: 0 0 5px;
  font-size: 21px;
  line-height: 1.2;
}

.mobile-shop-detail-hero p {
  margin: 0;
  color: #607572;
}

.mobile-shop-detail-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 12px;
  margin: 14px 0;
  padding: 10px;
  border: 1px solid rgba(118, 158, 149, 0.28);
  border-radius: 14px;
  background: #f8fffb;
}

.mobile-shop-detail-grid span {
  color: #607572;
}

.mobile-shop-note {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid rgba(118, 158, 149, 0.28);
  border-radius: 14px;
  background: #fff;
}

.mobile-shop-note p {
  margin: 0;
  color: #365350;
  white-space: pre-wrap;
}

.mobile-shop-detail-actions,
.mobile-shop-assistant-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
}

.mobile-shop-assistant-list {
  display: grid;
  gap: 10px;
  min-height: 260px;
  max-height: 48vh;
  overflow: auto;
  padding: 12px;
  border: 1px solid rgba(118, 158, 149, 0.35);
  border-radius: 14px;
  background: linear-gradient(180deg, #fbfffe 0%, #f2fbf8 100%);
}

.mobile-shop-assistant-message {
  width: min(92%, 100%);
  display: grid;
  gap: 6px;
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.55;
}

.mobile-shop-assistant-message.helper {
  border: 1px solid rgba(15, 133, 116, 0.25);
  background: #f3fbf7;
  color: #062d30;
}

.mobile-shop-assistant-message.mine {
  justify-self: end;
  background: #0f8574;
  color: #fff;
}

.mobile-shop-assistant-message.is-streaming {
  width: min(260px, 72%);
}

.mobile-shop-assistant-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 18px;
}

.mobile-shop-assistant-typing span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.36;
  animation: mobile-shop-typing 1s ease-in-out infinite;
}

.mobile-shop-assistant-typing span:nth-child(2) {
  animation-delay: 0.16s;
}

.mobile-shop-assistant-typing span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes mobile-shop-typing {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.32;
  }
  40% {
    transform: translateY(-4px);
    opacity: 0.9;
  }
}

.mobile-shop-assistant-role {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  opacity: 0.78;
}

.mobile-shop-assistant-title {
  font-size: 15px;
  font-weight: 800;
}

.mobile-shop-assistant-options {
  display: grid;
  gap: 8px;
}

.mobile-shop-assistant-option-grid {
  display: grid;
  gap: 8px;
}

.mobile-shop-assistant-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid rgba(15, 133, 116, 0.25);
  background: #fff;
  color: #062d30;
  font-size: 14px;
  line-height: 1.45;
}

.mobile-shop-assistant-option-index {
  flex: 0 0 auto;
  min-width: 22px;
  color: #0b7c69;
  font-weight: 900;
}

.mobile-shop-assistant-option:disabled {
  opacity: 0.62;
}

.mobile-shop-assistant-option.is-active {
  border-color: rgba(15, 133, 116, 0.6);
  background: #e9f9f3;
}

.mobile-shop-assistant-summary {
  margin-top: 2px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(118, 158, 149, 0.22);
  color: #214442;
  font-size: 13px;
}

.mobile-shop-checkout {
  width: 100%;
  margin-top: 8px;
}

.mobile-shop-check-card {
  display: grid;
  gap: 10px;
}

.mobile-shop-check-card label {
  display: grid;
  gap: 4px;
  color: #4c6664;
  font-weight: 800;
}

.mobile-shop-order-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(118, 158, 149, 0.32);
  border-radius: 14px;
  background: #fff;
}

.mobile-shop-qty {
  display: grid;
  grid-template-columns: 30px 34px 30px;
  align-items: center;
  border: 1px solid rgba(118, 158, 149, 0.32);
  border-radius: 999px;
  overflow: hidden;
}

.mobile-shop-qty button {
  border: 0;
  background: #f3fbf7;
  color: #0f8574;
  font-size: 18px;
  font-weight: 900;
}

.mobile-shop-qty strong {
  text-align: center;
}

.mobile-shop-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  background: #fff7df;
  color: #3b2d00;
}

.mobile-shop-order-status {
  padding: 9px 10px;
  border: 1px solid #b8ddd4;
  border-radius: 12px;
  background: #eefaf6;
  color: #006b5d;
  font-weight: 800;
}

.mobile-shop-total b {
  color: #d9431f;
  font-size: 24px;
}

.mobile-shop-fee-lines {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0 0;
  padding: 8px 10px;
  border: 1px solid #dbe9df;
  border-radius: 12px;
  background: #fbfffb;
  color: #47635d;
  font-weight: 800;
}

.mobile-pay-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.42);
}

.mobile-pay-modal-card {
  width: min(92vw, 460px);
  padding: 18px;
  border: 1px solid #b7d6ce;
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(1, 63, 56, 0.24);
}

.mobile-pay-modal-card strong {
  display: block;
  color: #043d39;
  font-size: 24px;
  margin-bottom: 8px;
}

.mobile-pay-modal-card p {
  margin: 0 0 14px;
  color: #4b625d;
  line-height: 1.5;
}

.mobile-pay-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 430px) {
  .mobile-grid-2,
  .mobile-code-row {
    grid-template-columns: 1fr;
  }

  .mobile-chat-actions {
    grid-template-columns: 1fr;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", "PingFang SC", sans-serif;
  font-size: 16px;
  line-height: 1.12;
  background:
    radial-gradient(circle at 18% 0%, rgba(13, 118, 108, 0.12), transparent 28%),
    linear-gradient(315deg, rgba(39, 90, 122, 0.08), transparent 30%),
    var(--bg);
}

body[data-ui-theme="modern"] {
  background:
    linear-gradient(135deg, rgba(245, 247, 250, 0.96), rgba(235, 243, 255, 0.98)),
    repeating-linear-gradient(90deg, rgba(15, 82, 186, 0.04) 0 1px, transparent 1px 56px),
    var(--bg);
  font-family: Inter, "Microsoft YaHei", "Segoe UI", "PingFang SC", sans-serif;
}

body:not(.is-authenticated) .app-shell {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 6px;
  overflow-x: hidden;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(245, 247, 250, 0.96), rgba(235, 243, 255, 0.98)),
    repeating-linear-gradient(90deg, rgba(15, 82, 186, 0.05) 0 1px, transparent 1px 56px);
}

.login-screen[hidden],
[hidden] {
  display: none !important;
}

.login-theme-switch {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 101;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid #e5e6eb;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 28px rgba(15, 82, 186, 0.12);
  backdrop-filter: blur(12px);
}

.login-theme-switch span {
  padding: 0 8px;
  color: #4e5969;
  font-size: 12px;
  font-weight: 900;
}

.login-theme-switch button {
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: #4e5969;
  background: transparent;
  font-size: 13px;
  font-weight: 900;
}

.login-theme-switch button:hover,
.login-theme-switch button:focus-visible {
  color: #1677ff;
  background: #f0f7ff;
}

.login-theme-switch button.active {
  color: #fff;
  background: #1677ff;
  box-shadow: 0 6px 14px rgba(22, 119, 255, 0.2);
}

.login-card {
  width: min(960px, calc(100vw - 48px));
  min-height: 520px;
  padding: 0;
  overflow: hidden;
  border: 1px solid #e5e6eb;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 82, 186, 0.16);
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(360px, 1.08fr);
  min-height: 520px;
}

.login-brand-panel,
.login-form-panel,
.login-left,
.login-right {
  min-width: 0;
}

.login-brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100%;
  padding: 24px 24px 18px;
  color: #fff;
  background:
    radial-gradient(rgba(255, 255, 255, 0.14) 1px, transparent 1px),
    #3158bd;
  background-size: 22px 22px;
}

.login-brand-main {
  display: grid;
  align-content: start;
  gap: 0;
}

.login-brand-panel h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(28px, 3.4vw, 34px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.15;
}

.login-brand-subtitle {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.45;
}

.login-brand-slogan {
  margin: 66px 0 0;
  color: #fff;
  font-size: clamp(18px, 2.2vw, 22px);
  font-weight: 500;
  line-height: 1.55;
}

.login-brand-lines {
  display: grid;
  gap: 7px;
  margin-top: 16px;
}

.login-brand-lines p {
  margin: 0;
  color: rgba(255, 255, 255, 0.95);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.45;
}

.login-brand-footer {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
}

.login-form-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  padding: 54px 58px;
}

.login-heading {
  display: grid;
  gap: 8px;
}

.login-card h1 {
  margin: 0;
  color: #1d2129;
  font-size: clamp(26px, 3vw, 34px);
  letter-spacing: 0;
  line-height: 1.15;
}

.login-card .login-brand-panel h1 {
  color: #fff;
  font-size: clamp(28px, 3.4vw, 34px);
  font-weight: 900;
}

.login-hint {
  max-width: 360px;
  margin: 0;
  color: #86909c;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.7;
}

.login-fields {
  display: grid;
  gap: 16px;
  max-width: 360px;
}

.login-fields label {
  color: #4e5969;
  font-size: 14px;
  font-weight: 800;
}

.login-fields input {
  min-height: 44px;
  margin-top: 7px;
  border: 1px solid #dcdee6;
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
  color: #1d2129;
  font-size: 16px;
}

.login-fields input:focus {
  border-color: #1677ff;
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.14);
}

.login-choice-block {
  display: grid;
  gap: 6px;
}

.login-choice-block > strong {
  color: var(--ink);
  font-size: 17px;
  line-height: 1.1;
}

.login-role-panel {
  max-width: 380px;
}

.login-hospital-panel {
  min-height: 0;
  align-self: stretch;
}

.login-choice-title {
  color: var(--accent-strong);
  font-weight: 900;
}

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

.role-login-cards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.login-choice-card {
  position: relative;
  min-height: 34px;
  overflow: hidden;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  background: #fffefa;
  text-align: left;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.login-choice-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(110deg, transparent 20%, rgba(255, 255, 255, 0.32), transparent 70%);
  opacity: 0;
  transform: translateX(-60%);
  transition: opacity 160ms ease, transform 260ms ease;
}

.login-choice-card:hover,
.login-choice-card:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 7px 16px rgba(13, 118, 108, 0.14), inset 0 0 0 1px rgba(13, 118, 108, 0.16);
  transform: translateY(-1px) scale(1.01);
}

.login-choice-card:hover::after,
.login-choice-card:focus-visible::after {
  opacity: 1;
  transform: translateX(60%);
}

.login-choice-card:focus-visible {
  outline: 2px solid rgba(13, 118, 108, 0.18);
  outline-offset: 2px;
}

.login-choice-card span {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.login-choice-card.active {
  border-color: var(--accent);
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 8px 18px rgba(13, 118, 108, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.34);
}

.login-choice-card.active span {
  color: #dff8ef;
}

.login-clinic-list {
  grid-template-columns: 1fr;
  align-content: start;
  max-height: min(370px, calc(100vh - 160px));
  min-height: 240px;
  overflow-y: auto;
  padding: 1px 6px 1px 1px;
  scrollbar-gutter: stable;
}

.login-clinic-list::-webkit-scrollbar {
  width: 8px;
}

.login-clinic-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(13, 118, 108, 0.36);
}

.login-clinic-list .clinic-card {
  min-height: 52px;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 17px;
}

.login-clinic-list .clinic-card span {
  font-size: 12px;
}

.login-submit {
  width: min(360px, 100%);
  min-height: 46px;
  margin-top: 2px;
  border-radius: 8px;
  background: #1677ff;
  font-size: 16px;
  box-shadow: 0 12px 26px rgba(22, 119, 255, 0.22);
}

.login-submit:hover,
.login-submit:focus-visible {
  background: #0f52ba;
  box-shadow: 0 14px 28px rgba(15, 82, 186, 0.24);
}

.login-screen[data-login-theme="classic"] {
  padding: 16px;
  background:
    radial-gradient(circle at 18% 16%, rgba(13, 118, 108, 0.14), transparent 28%),
    radial-gradient(circle at 82% 72%, rgba(250, 204, 21, 0.12), transparent 32%),
    linear-gradient(140deg, rgba(255, 252, 246, 0.96), rgba(239, 247, 242, 0.97));
}

.login-screen[data-login-theme="classic"] .login-theme-switch {
  border-color: rgba(13, 118, 108, 0.18);
  box-shadow: 0 10px 26px rgba(17, 35, 38, 0.12);
}

.login-screen[data-login-theme="classic"] .login-theme-switch button:hover,
.login-screen[data-login-theme="classic"] .login-theme-switch button:focus-visible {
  color: var(--accent-strong);
  background: rgba(13, 118, 108, 0.08);
}

.login-screen[data-login-theme="classic"] .login-theme-switch button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 6px 14px rgba(13, 118, 108, 0.18);
}

.login-screen[data-login-theme="classic"] .login-card {
  width: min(760px, calc(100vw - 32px));
  min-height: 430px;
  border-color: var(--line-strong);
  border-radius: 16px;
  background: rgba(251, 252, 248, 0.98);
  box-shadow: 0 24px 80px rgba(17, 35, 38, 0.22);
}

.login-screen[data-login-theme="classic"] .login-layout {
  grid-template-columns: minmax(260px, 0.92fr) minmax(300px, 1.08fr);
  min-height: 430px;
}

.login-screen[data-login-theme="classic"] .login-brand-panel {
  padding: 24px 24px 18px;
  background:
    radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1px),
    linear-gradient(150deg, #0d766c, #075d56);
  background-size: 22px 22px;
}

.login-screen[data-login-theme="classic"] .login-brand-panel h1 {
  font-size: clamp(28px, 3.4vw, 34px);
  letter-spacing: 0;
}

.login-screen[data-login-theme="classic"] .login-brand-slogan {
  margin-top: 58px;
}

.login-screen[data-login-theme="classic"] .login-form-panel {
  gap: 18px;
  padding: 36px 38px;
}

.login-screen[data-login-theme="classic"] .login-card h1 {
  color: var(--ink);
  font-size: clamp(28px, 3vw, 36px);
}

.login-screen[data-login-theme="classic"] .login-hint {
  color: var(--muted);
}

.login-screen[data-login-theme="classic"] .login-fields {
  gap: 10px;
  max-width: 300px;
}

.login-screen[data-login-theme="classic"] .login-fields label {
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
}

.login-screen[data-login-theme="classic"] .login-fields input {
  min-height: 34px;
  border-width: 0 0 1px;
  border-color: var(--line-strong);
  border-radius: 0 0 7px 7px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.72);
}

.login-screen[data-login-theme="classic"] .login-fields input:focus {
  border-color: var(--accent);
  box-shadow: 0 3px 0 rgba(13, 118, 108, 0.12);
}

.login-screen[data-login-theme="classic"] .login-submit {
  min-height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 8px 18px rgba(13, 118, 108, 0.2);
}

.login-screen[data-login-theme="classic"] .login-submit:hover,
.login-screen[data-login-theme="classic"] .login-submit:focus-visible {
  background: linear-gradient(135deg, var(--accent-strong), #075d54);
  box-shadow: 0 10px 22px rgba(13, 118, 108, 0.24);
}

@media (max-width: 980px) {
  .login-screen {
    align-items: flex-start;
    overflow-y: auto;
  }

  .login-card {
    min-height: 0;
    width: min(620px, calc(100vw - 32px));
  }

  .login-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .login-brand-panel {
    min-height: 260px;
    padding: 28px;
  }

  .login-brand-slogan {
    margin-top: 34px;
  }

  .login-brand-footer {
    margin-top: 44px;
  }

  .login-form-panel {
    padding: 32px;
  }

  .login-screen[data-login-theme="classic"] .login-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .login-screen[data-login-theme="classic"] .login-card {
    min-height: 0;
  }

  .login-screen[data-login-theme="classic"] .login-form-panel {
    padding: 28px;
  }

  .login-fields,
  .login-role-panel {
    max-width: none;
  }

  .login-clinic-list {
    max-height: 300px;
    min-height: 180px;
  }

  .login-clinic-list .clinic-card {
    min-height: 46px;
    font-size: 16px;
  }
}

@media (max-width: 640px) {
  .login-theme-switch {
    position: fixed;
    top: 10px;
    right: 10px;
    left: 10px;
    justify-content: center;
  }

  .login-screen {
    padding-top: 70px;
  }
}

.admin-login-dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
}

.admin-login-form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.admin-login-head {
  min-height: auto;
  padding: 0 0 12px;
}

.admin-login-head p:last-child {
  max-width: 420px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
}

.admin-login-grid {
  display: grid;
  gap: 12px;
}

.admin-login-grid label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.admin-login-grid select {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 7px 10px;
  color: var(--ink);
  background: var(--paper);
  font: inherit;
}

.admin-login-grid select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.14);
}

.user-pill {
  color: #9a3412;
  border-color: #fdba74;
  background: #fff7ed;
  font-weight: 900;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  padding: 4px 8px;
  margin-bottom: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(251, 252, 248, 0.96);
  box-shadow: var(--shadow);
}

.brand h1,
.patient-strip h2,
.dialog-head h2 {
  margin: 1px 0 0;
  font-size: 25px;
  letter-spacing: -0.03em;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 560px;
}

.brand-clock {
  align-self: flex-end;
  margin-bottom: 3px;
  min-width: 190px;
  justify-content: center;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-actions,
.tag-row,
.flow-line,
.rx-toolbar {
  display: flex;
  align-items: center;
  gap: var(--gap);
  flex-wrap: wrap;
}

.doctor-grid {
  display: grid;
  grid-template-columns: minmax(430px, 30vw) minmax(760px, 1fr);
  gap: 4px;
  align-items: start;
}

.video-sidebar {
  display: grid;
  gap: 4px;
  align-self: start;
  position: sticky;
  top: 52px;
  height: calc(100vh - 60px);
  min-height: 620px;
}

.video-card {
  margin-top: 0;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.video-copy-link {
  min-height: 28px;
  padding: 3px 10px;
  border-color: #a7d7cd;
  color: var(--accent-strong);
  background: #f7fffb;
  font-size: 14px;
  white-space: nowrap;
}

.video-copy-link:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.video-stage {
  display: grid;
  grid-template-rows: minmax(260px, 1.25fr) minmax(220px, 0.9fr);
  gap: 4px;
  margin-top: 0;
  flex: 1;
  min-height: 0;
}

.video-tile {
  display: grid;
  align-content: end;
  min-height: 0;
  padding: 10px 10px 58px;
  border: 1px solid #b9d5cc;
  border-radius: 12px;
  color: white;
  background:
    radial-gradient(circle at 78% 10%, rgba(255, 255, 255, 0.28), transparent 18%),
    linear-gradient(145deg, #0f766e, #164e63);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  position: relative;
  overflow: hidden;
}

.video-tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.video-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 38%, rgba(0, 0, 0, 0.44));
  z-index: 1;
}

.patient-tile {
  min-height: 260px;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 255, 255, 0.24), transparent 20%),
    linear-gradient(145deg, #134e4a, #9a3412);
}

.doctor-tile {
  min-height: 220px;
}

.video-tile span {
  opacity: 0.76;
  font-size: 13px;
  font-weight: 800;
  position: relative;
  z-index: 2;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.38);
}

.video-tile strong {
  font-size: 22px;
  letter-spacing: -0.04em;
  position: relative;
  z-index: 2;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.38);
}

.video-inline-controls {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 8px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: none;
}

.audio-meter {
  flex: 1;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
}

.audio-meter i {
  display: block;
  width: 3%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6ee7b7, #fbbf24, #f97316);
  transition: width 90ms linear;
}

.video-inline-controls button {
  pointer-events: auto;
  min-height: 28px;
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 999px;
  color: #fff;
  background: rgba(13, 118, 108, 0.78);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.video-inline-controls button.is-off {
  color: #fff7ed;
  border-color: rgba(254, 202, 202, 0.9);
  background: rgba(180, 35, 24, 0.82);
}

.video-popout-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 999px;
  color: #fff;
  background: rgba(6, 78, 59, 0.72);
  backdrop-filter: blur(10px);
  font-size: 14px;
  font-weight: 900;
}

body.video-floating::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(4, 22, 19, 0.58);
  backdrop-filter: blur(3px);
}

.patient-tile.is-floating {
  position: fixed;
  inset: 4vh 5vw;
  z-index: 80;
  min-height: auto;
  border-radius: 18px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.45);
}

.patient-tile.is-floating strong {
  font-size: clamp(32px, 5vw, 68px);
}

.patient-tile.is-floating span {
  font-size: 20px;
}

.patient-tile.is-floating .video-popout-btn {
  top: 16px;
  right: 16px;
  min-height: 40px;
  padding: 8px 18px;
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.92);
}

.patient-tile.is-floating .video-inline-controls {
  left: 20px;
  right: 20px;
  bottom: 20px;
  padding: 10px;
}

.patient-consult-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% 0%, rgba(13, 118, 108, 0.22), transparent 30%),
    linear-gradient(140deg, #f7fbf4, #e8f1ec);
}

.patient-consult-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.patient-consult-card {
  width: min(1120px, 100%);
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(251, 252, 248, 0.98);
  box-shadow: 0 24px 70px rgba(17, 35, 38, 0.16);
}

.patient-consult-card h1 {
  margin: 2px 0 4px;
  font-size: clamp(28px, 4vw, 46px);
}

.patient-session-hint,
.patient-video-status {
  color: var(--muted);
  font-weight: 800;
}

.patient-video-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 8px;
  margin-top: 12px;
}

.patient-video-tile {
  position: relative;
  display: grid;
  align-content: end;
  min-height: 430px;
  overflow: hidden;
  padding: 14px 14px 62px;
  border: 1px solid #b9d5cc;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(145deg, #0f766e, #164e63);
}

.patient-video-tile.local {
  min-height: 260px;
  background: linear-gradient(145deg, #134e4a, #9a3412);
}

.patient-video-tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.patient-video-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, 0.45));
}

.patient-video-tile span,
.patient-video-tile strong {
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.patient-video-tile span {
  font-weight: 900;
}

.patient-video-tile strong {
  font-size: clamp(26px, 4vw, 48px);
}

.patient-consent-box {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: #f3fbf7;
}

.patient-consent-box label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 900;
}

.patient-consent-box input {
  width: auto;
  min-height: auto;
  transform: scale(1.35);
}

.patient-video-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.patient-video-actions .btn {
  min-height: 46px;
  font-size: 20px;
}

.patient-video-status {
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  background: #eefaf7;
}

.patient-video-status[data-tone="ok"] {
  color: var(--ok);
}

.patient-video-status[data-tone="bad"] {
  color: var(--bad);
  background: #fff1f2;
}

.video-status-grid,
.video-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 5px;
}

.video-card .video-status-grid,
.video-card .check-line,
.video-patient-entry-line {
  display: none;
}

.video-actions .btn {
  flex: 1;
  min-width: 118px;
}

.check-line {
  display: flex;
  align-items: center;
  grid-template-columns: none;
  gap: 6px;
  margin-top: 5px;
  color: #334e55;
  font-weight: 800;
}

.check-line input {
  width: auto;
  min-height: auto;
}

.video-emr-preview {
  display: grid;
  gap: 3px;
  min-height: 74px;
  margin-top: 5px;
  padding: 8px;
  border: 1px dashed #9bc7b8;
  border-radius: 10px;
  color: var(--muted);
  background: #f3fbf7;
}

.video-emr-preview strong {
  color: var(--accent-strong);
}

.emr-ai-strip {
  display: none !important;
  grid-template-columns: minmax(320px, 1.25fr) minmax(280px, 1fr);
  gap: var(--gap);
  margin-top: 4px;
  padding: 6px;
  border: 1px dashed #9bc7b8;
  border-radius: 10px;
  background: #f3fbf7;
}

.emr-ai-strip textarea {
  min-height: 82px;
}

.emr-ai-tools {
  display: grid;
  align-content: start;
  gap: 4px;
}

.emr-ai-tools small {
  color: #5c746f;
  font-weight: 800;
}

.role-page[hidden] {
  display: none !important;
}

.role-dashboard,
.page-card {
  min-height: calc(100vh - 64px);
}

.page-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 96px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 12% 0%, rgba(13, 118, 108, 0.16), transparent 34%),
    rgba(251, 252, 248, 0.97);
  box-shadow: var(--shadow);
}

.page-hero h2 {
  margin: 2px 0 4px;
  font-size: 31px;
  letter-spacing: -0.04em;
}

.role-dashboard .page-hero h2 {
  display: none;
}

.page-hero span,
.role-note {
  color: var(--muted);
}

.hero-actions,
.role-card-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.role-card-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.7fr) minmax(280px, 0.3fr);
  margin-top: 8px;
}

.role-action-box {
  margin-top: 8px;
  max-width: 760px;
}

.pharmacy-hero .hero-actions {
  justify-content: flex-end;
}

.pharmacy-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.pharmacy-menu {
  position: sticky;
  top: 8px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 72vh;
  padding: 10px;
  border: 1px solid #7da0d9;
  border-radius: 14px;
  background: linear-gradient(180deg, #d9e6ff 0%, #6f88dd 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55), var(--shadow);
}

.pharmacy-menu strong {
  display: block;
  padding: 7px 10px;
  border-radius: 10px;
  color: #fff;
  background: #2863ca;
  letter-spacing: 0.08em;
}

.pharmacy-menu button {
  position: relative;
  width: 100%;
  padding: 8px 10px 8px 34px;
  border: 0;
  border-bottom: 1px solid rgba(41, 95, 181, 0.35);
  background: rgba(244, 249, 255, 0.42);
  color: #075fb7;
  text-align: left;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.pharmacy-menu button::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 50%;
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: linear-gradient(135deg, #0b9d8b, #17c7c2);
  box-shadow: 2px 2px 0 #083b70;
  transform: translateY(-50%) rotate(-18deg);
}

.pharmacy-menu button.active,
.pharmacy-menu button:hover {
  border-radius: 10px;
  background: #fff9d8;
  color: #b12a23;
}

.pharmacy-workbench {
  min-width: 0;
}

.pharmacy-module-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.pharmacy-module-head h3 {
  margin: 0;
  font-size: 24px;
}

.pharmacy-module-head span {
  color: var(--muted);
}

.pharmacy-module-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.pharmacy-module-actions span {
  color: var(--muted);
  white-space: nowrap;
}

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

.pharmacy-prescription-form {
  grid-template-columns: minmax(220px, 1fr) 220px 240px;
}

.pharmacy-ims-panel {
  overflow: hidden;
}

.pharmacy-filter-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 160px auto;
  gap: 8px;
  margin: 8px 0;
}

.pharmacy-bill-form {
  display: grid;
  gap: 5px;
  margin-top: 4px;
}

.pharmacy-bill-head,
.pharmacy-line-editor {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 5px 7px;
}

.pharmacy-bill-form label {
  gap: 2px;
  line-height: 1.15;
}

.pharmacy-bill-form input,
.pharmacy-bill-form select {
  min-height: 34px;
  padding: 5px 8px;
  border-radius: 9px;
}

.pharmacy-bill-head .wide,
.pharmacy-line-editor .wide {
  grid-column: span 3;
}

.pharmacy-bill-toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #fbfff8, #edf6f0);
}

.pharmacy-bill-toolbar .btn {
  min-width: 88px;
  padding: 6px 10px;
}

.pharmacy-line-editor {
  padding: 6px;
  border: 1px dashed #9bbab3;
  border-radius: 14px;
  background: #fcfff8;
}

.pharmacy-bill-lines {
  max-height: 34vh;
}

.pharmacy-bill-lines tfoot td {
  position: sticky;
  bottom: 0;
  background: #eef5ef;
  color: var(--brand-dark);
  font-weight: 800;
  text-align: right;
}

.pharmacy-data-table {
  max-height: 36vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcf8;
}

.pharmacy-data-table table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1080px;
}

.pharmacy-data-table th,
.pharmacy-data-table td {
  padding: 5px 7px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.pharmacy-data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef5ef;
  color: #334e55;
}

.pharmacy-data-table tr {
  cursor: pointer;
}

.pharmacy-data-table tr:hover {
  background: #eefaf7;
}

.pharmacy-data-table tr.selected {
  background: #d9e9ff;
  outline: 2px solid #4f82d6;
}

.pharmacy-data-table td small,
.pharmacy-data-table td strong {
  display: block;
}

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

  .pharmacy-menu {
    position: static;
    min-height: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pharmacy-menu strong {
    grid-column: 1 / -1;
  }

  .pharmacy-prescription-form {
    grid-template-columns: 1fr;
  }

  .pharmacy-bill-head,
  .pharmacy-line-editor {
    grid-template-columns: 1fr;
  }

  .pharmacy-bill-head .wide,
  .pharmacy-line-editor .wide {
    grid-column: auto;
  }
}

.clinical-card,
.action-card,
.box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(251, 252, 248, 0.97);
  box-shadow: var(--shadow);
}

.clinical-card,
.action-card {
  padding: 5px;
}

.box {
  padding: 5px;
  margin-top: 4px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-height: 24px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--line);
}

.section-title strong {
  font-size: 16px;
}

.mobile-chat-section-title {
  align-items: flex-start;
  gap: 10px;
}

.mobile-consult-title-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.mobile-consult-end {
  min-height: 32px;
  padding: 4px 13px;
  border-radius: 13px;
  font-size: 14px;
  white-space: nowrap;
  box-shadow: 0 7px 16px rgba(15, 133, 116, 0.22);
}

.mobile-consult-end[hidden] {
  display: none !important;
}

.rx-section-title {
  justify-content: flex-start;
  gap: 18px;
}

.rx-title-action {
  min-width: 112px;
  min-height: 28px;
  padding: 3px 14px;
  font-size: 14px;
}

.section-title small,
.selected-rx small,
.selected-rx span {
  color: var(--muted);
  font-size: 14px;
}

.pill,
.tag-row span,
.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--muted);
  font-size: 14px;
}

.patient-strip {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  padding: 3px 2px;
  border-bottom: 1px solid var(--line);
}

.rx-type-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, 30px);
  gap: 4px;
  align-self: center;
  padding: 0;
}

.rx-type-switch button {
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--accent-strong);
  background: #fff;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.rx-type-switch button.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 118, 108, 0.12);
}

body[data-ui-theme="modern"] .topbar {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

body[data-ui-theme="modern"] .brand h1,
body[data-ui-theme="modern"] .patient-strip h2,
body[data-ui-theme="modern"] .dialog-head h2 {
  letter-spacing: 0;
}

body[data-ui-theme="modern"] .clinical-card,
body[data-ui-theme="modern"] .action-card,
body[data-ui-theme="modern"] .box,
body[data-ui-theme="modern"] dialog,
body[data-ui-theme="modern"] .page-dialog,
body[data-ui-theme="modern"] .medicine-dialog,
body[data-ui-theme="modern"] .master-data-dialog {
  border-color: var(--line);
  background: var(--paper);
  box-shadow: var(--shadow);
}

body[data-ui-theme="modern"] .page-hero {
  border-color: var(--line);
  background:
    radial-gradient(circle at 12% 0%, rgba(22, 119, 255, 0.12), transparent 34%),
    var(--paper);
  box-shadow: var(--shadow);
}

body[data-ui-theme="modern"] .btn {
  border-radius: var(--radius);
}

body[data-ui-theme="modern"] .btn.primary,
body[data-ui-theme="modern"] .master-tabs button.active,
body[data-ui-theme="modern"] .rx-type-switch button.active {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
}

body[data-ui-theme="modern"] .btn.ghost,
body[data-ui-theme="modern"] .nav-actions .btn,
body[data-ui-theme="modern"] .nav-actions .pill {
  background: rgba(255, 255, 255, 0.88);
}

body[data-ui-theme="modern"] .nav-actions .btn.primary,
body[data-ui-theme="modern"].tcm-mode .nav-actions .btn.primary {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

body[data-ui-theme="modern"] .query-table table,
body[data-ui-theme="modern"] .pharmacy-data-table,
body[data-ui-theme="modern"] .master-table table,
body[data-ui-theme="modern"] .role-permission-table table,
body[data-ui-theme="modern"] .billing-preview-table {
  background: var(--paper);
}

body[data-ui-theme="modern"] .query-table th,
body[data-ui-theme="modern"] .pharmacy-data-table th,
body[data-ui-theme="modern"] .master-table th,
body[data-ui-theme="modern"] .role-permission-table th,
body[data-ui-theme="modern"] .billing-preview-table th {
  color: #1d2129;
  background: #f5f7fa;
}

body[data-ui-theme="modern"] .query-table tbody tr:hover,
body[data-ui-theme="modern"] .query-table tbody tr.selected,
body[data-ui-theme="modern"] .pharmacy-data-table tr:hover,
body[data-ui-theme="modern"] .master-table tr:hover {
  background: #f0f7ff;
}

body[data-ui-theme="modern"] .pharmacy-data-table tr.selected,
body[data-ui-theme="modern"] .master-table tr.active td {
  background: #e8f3ff;
  outline-color: var(--accent);
}

body.tcm-mode {
  --bg: #e8f4ff;
  --paper: #ffffff;
  --paper-2: #f6f8fb;
  --line: #dcdfe6;
  --line-strong: #d5dbe3;
  --ink: #303133;
  --muted: #606266;
  --accent: #2f6ead;
  --accent-strong: #214874;
  background: #e8f4ff;
  color: #303133;
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
}

body.tcm-mode .topbar {
  min-height: 56px;
  margin: 0;
  padding: 0 24px;
  border: 0;
  border-radius: 0;
  background: #214874;
  box-shadow: none;
}

body.tcm-mode .brand h1,
body.tcm-mode .brand .eyebrow,
body.tcm-mode .brand-clock,
body.tcm-mode .nav-actions,
body.tcm-mode .nav-actions .pill {
  color: #fff;
}

body.tcm-mode .brand h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
}

body.tcm-mode .brand .eyebrow,
body.tcm-mode .brand-clock {
  display: none;
}

body.tcm-mode .nav-actions .btn,
body.tcm-mode .nav-actions .pill {
  min-height: 32px;
  border-color: transparent;
  border-radius: 3px;
  background: transparent;
  color: #fff;
  box-shadow: none;
  font-size: 14px;
}

body.tcm-mode .nav-actions .btn.primary {
  background: #173b68;
}

body.tcm-mode .doctor-grid--tcm {
  grid-template-columns: minmax(300px, 360px) minmax(900px, 1fr);
  gap: 0;
  align-items: stretch;
  background: #e8f4ff;
}

body.tcm-mode .doctor-grid--tcm .video-sidebar {
  top: 56px;
  height: calc(100vh - 56px);
  min-height: 638px;
  padding: 8px 16px 0;
  border-right: 1px solid #dcdfe6;
  background: #eaf4fd;
}

body.tcm-mode .doctor-grid--tcm .video-card,
body.tcm-mode .doctor-grid--tcm .box {
  border-color: #dcdfe6;
  border-radius: 3px;
  background: #f7fbff;
  box-shadow: none;
}

body.tcm-mode .doctor-grid--tcm .clinical-card {
  min-height: calc(100vh - 56px);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #e8f4ff;
  box-shadow: none;
}

body.tcm-mode .doctor-grid--tcm .patient-strip {
  min-height: 56px;
  padding: 8px 24px;
  border-bottom: 1px solid #dcdfe6;
  background: #fff;
}

body.tcm-mode .doctor-grid--tcm .patient-main .eyebrow {
  margin: 0;
  color: #559b6e;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

body.tcm-mode .doctor-grid--tcm .patient-main h2 {
  margin: 0;
  color: #303133;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0;
}

body.tcm-mode .doctor-grid--tcm .patient-strip .tag-row {
  margin-top: 0;
  gap: 4px;
}

body.tcm-mode .doctor-grid--tcm .patient-strip .tag-row span,
body.tcm-mode .doctor-grid--tcm .rx-lock-banner {
  border-color: #fdba74;
  border-radius: 999px;
  background: #fff7ed;
  color: #c2410c;
  font-size: 14px;
  font-weight: 600;
}

body.tcm-mode .topbar .rx-type-switch {
  grid-template-columns: repeat(2, 34px);
  gap: 8px;
  padding: 0;
  align-self: center;
}

body.tcm-mode .topbar .rx-type-switch button {
  width: 34px;
  height: 28px;
  min-height: 28px;
  border: 1px solid #dcdfe6;
  border-radius: 3px;
  background: #fff;
  color: #303133;
  box-shadow: none;
  font-size: 14px;
  font-weight: 500;
}

body.tcm-mode .topbar .rx-type-switch button.active {
  border-color: #214874;
  background: #214874;
  color: #fff;
}

body.tcm-mode .doctor-grid--tcm .flow-line {
  display: none;
}

body.tcm-mode .doctor-grid--tcm .mobile-consult-compact {
  display: none;
}

#western-rx-workbench[hidden],
.tcm-workbench[hidden] {
  display: none !important;
}

.status-line[hidden] {
  display: none !important;
}

.patient-main {
  display: flex;
  flex-direction: column;
  min-width: 140px;
}

.patient-strip .tag-row {
  margin-top: 15px;
}

.patient-strip .tag-row span {
  color: #c2410c;
  border-color: #fdba74;
  background: #fff7ed;
  font-weight: 900;
}

.rx-lock-banner {
  margin-left: auto;
  padding: 5px 12px;
  border: 1px solid #f97316;
  border-radius: 999px;
  color: #9a3412;
  background: #fff7ed;
  font-size: 16px;
  font-weight: 900;
}

.flow-line {
  margin: 4px 0;
  padding: 3px;
  border-radius: 999px;
  background: #edf5ef;
}

.flow-line span {
  flex: 1;
  min-width: 70px;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--muted);
  text-align: center;
}

.flow-line .done {
  color: white;
  background: var(--accent);
}

.tcm-workbench {
  --tcm-primary: #2f6ead;
  --tcm-primary-dark: #214874;
  --tcm-page: #e8f4ff;
  --tcm-side: #f7fbff;
  --tcm-border: #dcdfe6;
  --tcm-border-soft: #ebeef5;
  --tcm-text: #303133;
  --tcm-muted: #606266;
  --tcm-placeholder: #a8abb2;
  --tcm-record-bg: #fffdeb;
  --tcm-success: #559b6e;
  margin-top: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: var(--tcm-page);
  color: var(--tcm-text);
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

.tcm-stage-tabs {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 10px 26px;
  border-bottom: 1px solid var(--tcm-border);
  background: #fff;
}

.tcm-stage-tabs button {
  position: relative;
  min-width: 126px;
  height: 32px;
  min-height: 32px;
  padding: 0 22px 0 28px;
  border: 1px solid var(--tcm-border);
  color: var(--tcm-text);
  background: linear-gradient(180deg, #ffffff 0%, #f4f4f5 100%);
  font-size: 14px;
  font-weight: 700;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 0 100%, 16px 50%);
  cursor: pointer;
}

.tcm-stage-tabs button.active {
  border-color: #5f8fc0;
  color: #17233d;
  background: linear-gradient(180deg, #f8fcff 0%, #e8f3ff 100%);
  box-shadow: inset 0 0 0 2px rgba(47, 110, 173, 0.22);
}

.tcm-symptom-alert {
  display: inline-flex;
  align-items: center;
  height: 32px;
  min-height: 32px;
  padding: 0 18px;
  border-radius: 999px;
  color: #e05a5a;
  background: #fff2f2;
  font-size: 14px;
  font-weight: 400;
}

.tcm-symptom-alert[hidden] {
  display: none !important;
}

.tcm-page-grid {
  display: grid;
  grid-template-columns: minmax(680px, 1fr) 360px;
  min-height: 638px;
}

.tcm-main-panel {
  min-width: 0;
  padding: 16px 24px 14px 24px;
  background: var(--tcm-page);
}

.tcm-main-panel[hidden] {
  display: none !important;
}

.tcm-board {
  overflow: hidden;
  border: 1px solid var(--tcm-border);
  border-radius: 3px;
  background: #fff;
}

.tcm-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 0 16px;
  border-bottom: 1px solid var(--tcm-border);
  color: var(--tcm-text);
  background: #fff;
  font-size: 14px;
  font-weight: 400;
}

.tcm-board-head strong {
  font-size: 14px;
  font-weight: 400;
}

.tcm-board-head .btn {
  min-height: 26px;
  padding: 3px 10px;
  border-radius: 3px;
  font-size: 14px;
  font-weight: 400;
}

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

.tcm-board-head #tcm-import-four-diagnosis {
  border-color: var(--tcm-success);
  background: var(--tcm-success);
  color: #fff;
}

.tcm-medical-table {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
}

.tcm-medical-table label {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  min-height: 41px;
  padding: 0 0 0 16px;
  border-bottom: 1px solid var(--tcm-border);
  color: var(--tcm-text);
  background: var(--tcm-record-bg);
  font-size: 14px;
  line-height: 1.45;
}

.tcm-medical-table label > textarea {
  width: 100%;
  min-height: 41px;
  height: auto;
  overflow: hidden;
  padding: 8px 10px;
  resize: none;
  border: 0;
  border-left: 1px solid var(--tcm-border);
  border-radius: 0;
  background: var(--tcm-record-bg);
  color: var(--tcm-text);
  font-size: 14px;
  line-height: 1.45;
}

.tcm-board-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-height: 42px;
  padding: 7px 14px;
  border-top: 1px solid var(--tcm-border);
  background: #fff;
}

.tcm-board-foot small {
  color: #7d8d9b;
  font-size: 12px;
}

.tcm-medical-table label > textarea::placeholder {
  color: var(--tcm-placeholder);
}

.tcm-rx-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border-bottom: 1px solid var(--tcm-border);
  background: #fff;
}

.tcm-rx-tabs span,
.tcm-rx-tabs button {
  height: 34px;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--tcm-border);
  border-bottom: 0;
  border-radius: 3px 3px 0 0;
  background: #fff;
  color: var(--tcm-muted);
  font-size: 14px;
  line-height: 34px;
}

.tcm-rx-tabs .active {
  color: var(--tcm-primary);
  font-weight: 500;
}

.tcm-rx-toolbar {
  display: grid;
  grid-template-columns: 240px 100px 110px;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--tcm-border);
  background: #fff;
}

.tcm-rx-toolbar select {
  height: 32px;
  border-color: var(--tcm-border);
  border-radius: 3px;
  background: #fff;
  color: var(--tcm-muted);
  font-size: 14px;
}

.tcm-herb-entry {
  height: 40px;
  padding: 0 16px;
  border-bottom: 1px dashed var(--tcm-border);
  color: var(--tcm-placeholder);
  background: #fff;
  font-size: 14px;
  line-height: 40px;
}

.tcm-treatment-result {
  min-height: 230px;
  padding: 12px 16px;
  color: var(--tcm-text);
  background: #fff;
  font-size: 14px;
}

.tcm-plan-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.tcm-plan-line strong {
  color: var(--tcm-primary);
  font-size: 14px;
  font-weight: 500;
}

.tcm-plan-line span {
  padding: 2px 8px;
  border: 1px solid #c6ddf5;
  border-radius: 3px;
  color: var(--tcm-primary);
  background: #eef6ff;
  font-size: 13px;
  font-weight: 400;
}

.tcm-herb-list {
  display: grid;
  gap: 6px;
  margin: 10px 0;
}

.tcm-herb-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.3fr) 90px minmax(150px, 1fr);
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--tcm-border-soft);
}

.tcm-herb-row span {
  color: var(--tcm-text);
  font-weight: 500;
}

.tcm-herb-row small {
  color: var(--tcm-muted);
}

.tcm-decoction {
  padding: 8px 10px;
  border-radius: 3px;
  background: #f5f7fa;
}

.tcm-plan-note {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid #d6e6f7;
  border-radius: 3px;
  background: #f4f9ff;
}

.tcm-plan-note.warning {
  border-color: #fed7aa;
  background: #fff7ed;
}

.tcm-diagnosis-table {
  display: grid;
  border-top: 1px solid var(--tcm-border);
  background: #fff;
}

.tcm-diagnosis-table label {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
  min-height: 40px;
  border-bottom: 1px solid var(--tcm-border);
  color: var(--tcm-text);
  font-size: 14px;
  line-height: 40px;
  padding-left: 16px;
}

.tcm-diagnosis-table input,
.tcm-diagnosis-table textarea {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-left: 1px solid var(--tcm-border);
  border-radius: 0;
  background: #fff;
  color: var(--tcm-text);
  resize: none;
  font-size: 14px;
}

.tcm-workbench input:focus,
.tcm-workbench select:focus,
.tcm-workbench textarea:focus {
  border-color: #409eff;
  box-shadow: none;
}

.tcm-ai-side {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
  padding: 14px 16px 20px;
  border-left: 1px solid var(--tcm-border);
  background: var(--tcm-side);
}

.tcm-ai-tabs {
  display: flex;
  align-items: center;
  gap: 26px;
  height: 40px;
  border-bottom: 1px solid var(--tcm-border);
  background: var(--tcm-side);
}

.tcm-ai-tabs[hidden] {
  display: none !important;
}

.tcm-ai-tabs button {
  height: 40px;
  min-height: 40px;
  padding: 0 2px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--tcm-muted);
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.tcm-ai-tabs button.active {
  color: #303133;
  border-bottom-color: #3b78c2;
}

.tcm-keyword-card {
  justify-self: end;
  display: grid;
  gap: 8px;
  min-width: 110px;
  margin-top: auto;
  padding: 8px 10px;
  border: 1px solid var(--tcm-border);
  border-radius: 3px;
  color: #303133;
  background: #fff;
  box-shadow: none;
  font-size: 14px;
}

.tcm-voice-panel {
  min-height: 0;
  overflow: auto;
  padding: 12px 14px;
  background: #fff;
}

.tcm-voice-state {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 8px;
  color: #526577;
  font-size: 13px;
}

#tcm-voice-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ba9b5;
}

.tcm-voice-panel.recording #tcm-voice-dot {
  background: #d64747;
  box-shadow: 0 0 0 4px rgba(214, 71, 71, 0.15);
  animation: tcm-recording-pulse 1.2s ease-in-out infinite;
}

.tcm-voice-panel.busy #tcm-voice-dot { background: #2d78bd; }
.tcm-voice-panel audio { width: 100%; margin-top: 10px; height: 32px; }
.tcm-voice-panel label { display: grid; gap: 6px; margin-top: 10px; color: #526577; font-size: 12px; }
.tcm-voice-panel textarea { min-height: 92px; resize: vertical; border: 1px solid #d9e1e8; padding: 8px; color: #26394a; background: #f8fafc; }
.tcm-voice-panel > small { display: block; margin-top: 8px; color: #8a98a5; line-height: 1.5; }

@keyframes tcm-recording-pulse { 50% { opacity: 0.45; } }

.tcm-risk-alert {
  margin-top: 10px;
  padding: 8px;
  border-left: 3px solid #cf4b43;
  background: #fff5f3;
  color: #8a302b;
}

.tcm-tongue-panel {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px;
  background: #fff;
}

.tcm-tongue-panel[hidden] { display: none; }
.tcm-tongue-guide { display: grid; gap: 4px; color: #526577; font-size: 12px; line-height: 1.5; }
.tcm-tongue-preview-wrap { overflow: hidden; width: 100%; aspect-ratio: 4 / 3; border: 1px solid #d9e1e8; background: #f3f6f8; }
.tcm-tongue-preview-wrap[hidden] { display: none; }
.tcm-tongue-preview-wrap img { width: 100%; height: 100%; object-fit: contain; }
.tcm-tongue-camera { display: grid; gap: 8px; }
.tcm-tongue-camera[hidden] { display: none; }
.tcm-tongue-camera-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid #d9e1e8;
  background: #17212a;
}
.tcm-tongue-camera video { width: 100%; height: 100%; object-fit: cover; }
.tongue-face-guide,
.tongue-mouth-guide,
.mobile-tongue-face-guide,
.mobile-tongue-mouth-guide {
  position: absolute;
  left: 50%;
  pointer-events: none;
  transform: translateX(-50%);
}
.tongue-face-guide,
.mobile-tongue-face-guide {
  top: 10%;
  width: 54%;
  height: 68%;
  border: 2px dashed rgba(255, 255, 255, 0.82);
  border-radius: 48% 48% 44% 44%;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.14);
}
.tongue-mouth-guide,
.mobile-tongue-mouth-guide {
  top: 57%;
  width: 30%;
  height: 16%;
  border: 2px dashed rgba(142, 255, 222, 0.92);
  border-radius: 999px 999px 55% 55%;
  background: rgba(15, 133, 116, 0.08);
}
.tcm-tongue-camera .inline-actions { justify-content: center; }
.tcm-tongue-result { padding: 9px; border: 1px solid #d9e1e8; color: #526577; background: #f8fafc; font-size: 12px; line-height: 1.55; }
.tcm-tongue-result p { margin: 6px 0; }
.tcm-tongue-result ul { margin: 5px 0 8px; padding-left: 18px; }
.tcm-tongue-quality.good { color: #2f7a58; }
.tcm-tongue-quality.bad { color: #a13b35; }
.tcm-tongue-panel > small { color: #8a98a5; line-height: 1.5; }

.tcm-visit-history-panel {
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

.tcm-visit-history-panel[hidden] { display: none; }

.tcm-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 38px;
  padding: 0 10px 0 12px;
  border-bottom: 1px solid var(--tcm-border);
  color: var(--tcm-text);
  font-size: 13px;
}

.tcm-history-head button {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border: 1px solid var(--tcm-border);
  border-radius: 3px;
  color: var(--tcm-muted);
  background: #fff;
  font-size: 17px;
  cursor: pointer;
}

.tcm-visit-history-list {
  max-height: 540px;
  overflow: auto;
}

.tcm-history-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 2px 10px;
  width: 100%;
  min-height: 58px;
  padding: 8px 10px 8px 12px;
  border: 0;
  border-bottom: 1px solid var(--tcm-border-soft);
  border-radius: 0;
  color: var(--tcm-muted);
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.tcm-history-row:hover,
.tcm-history-row:focus-visible {
  background: #f3f8fe;
  outline: none;
}

.tcm-history-row:disabled { cursor: wait; opacity: 0.65; }
.tcm-history-row strong { overflow: hidden; color: var(--tcm-text); font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.tcm-history-row span { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.tcm-history-row small { grid-column: 2; color: var(--tcm-placeholder); font-size: 12px; }
.tcm-history-date { grid-row: 1 / span 2; align-self: center; color: #526577 !important; }
.tcm-history-empty { margin: 0; padding: 28px 12px; color: var(--tcm-placeholder); font-size: 13px; text-align: center; }
.tcm-history-empty.error { color: #a13b35; }

.tcm-recording-popover {
  position: fixed;
  right: 378px;
  bottom: 24px;
  z-index: 1200;
  display: grid;
  grid-template-columns: auto auto minmax(52px, 1fr) 32px;
  align-items: center;
  gap: 9px;
  width: 216px;
  height: 44px;
  padding: 5px 6px 5px 12px;
  border: 1px solid #765cff;
  border-radius: 22px;
  color: #4f5968;
  background: #f8f7ff;
  box-shadow: 0 8px 22px rgba(67, 55, 150, 0.16);
  font-size: 12px;
}

.tcm-recording-popover[hidden] { display: none; }
.tcm-recording-popover time { font-variant-numeric: tabular-nums; }
.tcm-recording-popover.busy { grid-template-columns: auto 1fr 32px; }

.tcm-recording-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 24px;
}

.tcm-recording-wave i {
  width: 2px;
  height: 8px;
  border-radius: 1px;
  background: #526ef0;
  animation: tcm-wave 0.8s ease-in-out infinite alternate;
}

.tcm-recording-wave i:nth-child(2n) { height: 18px; animation-delay: -0.35s; }
.tcm-recording-wave i:nth-child(3n) { height: 12px; animation-delay: -0.6s; }
.tcm-recording-popover.busy .tcm-recording-wave { display: none; }

.tcm-recording-popover > button {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #c8c3ff, #8069ee);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.72), 0 0 0 2px rgba(126, 101, 242, 0.16);
  cursor: pointer;
}

.tcm-recording-popover > button span {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: #fff;
}

.tcm-recording-popover.busy > button { cursor: default; }
.tcm-recording-popover.busy > button span { display: none; }
.tcm-recording-popover.busy > button::after { content: "✦"; color: #fff; font-size: 14px; }

@keyframes tcm-wave { to { height: 22px; } }

@media (max-width: 1120px) {
  .tcm-recording-popover { right: 18px; }
}

.tcm-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tcm-keywords span {
  padding: 2px 7px;
  border-radius: 3px;
  color: #3b78c2;
  background: #ecf5ff;
  font-size: 12px;
  font-weight: 400;
}

.tcm-keyword-card ul,
.tcm-plan-note ul {
  margin: 0;
  padding-left: 18px;
}

.note-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
  margin-top: 4px;
}

.emr-note-field {
  min-width: 0;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.field-label-row .btn.mini {
  flex: 0 0 auto;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 4px 7px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(13, 118, 108, 0.12);
}

.rx-head input:disabled,
.rx-head select:disabled {
  color: #526b64;
  background: #eef5ef;
  cursor: not-allowed;
  opacity: 1;
}

.rx-form {
  display: grid;
  gap: var(--gap);
  margin-top: 4px;
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 8px;
  scrollbar-gutter: stable both-edges;
}

.rx-head {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) 96px 112px 112px 92px 70px minmax(250px, 2fr);
  gap: var(--gap);
  min-width: 980px;
}

.rx-patient-field {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.wide {
  grid-column: span 2;
}

.rx-diagnosis {
  min-width: 170px;
}

.rx-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-start;
  padding: 8px 0 2px;
  min-width: 1036px;
}

.rx-toolbar-split {
  justify-content: flex-start;
  align-items: center;
}

.rx-toolbar-left,
.rx-toolbar-right {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.rx-toolbar-right {
  justify-content: flex-start;
  margin-left: 28px;
}

.rx-toolbar .btn {
  min-height: 30px;
  padding: 3px 8px;
  font-size: 14px;
  white-space: nowrap;
}

.rx-toolbar .rx-action-equal {
  width: 144px;
  min-width: 144px;
  justify-content: center;
}

.signature-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #f6faf7;
  font-size: 13px;
  font-weight: 800;
}

.signature-status[data-state="signed"] {
  color: #047857;
  border-color: #86efac;
  background: #ecfdf5;
}

.signature-status[data-state="unsigned"] {
  color: #b45309;
  border-color: #fcd34d;
  background: #fffbeb;
}

.signature-status[data-state="locked"] {
  color: #9a3412;
  border-color: #fdba74;
  background: #fff7ed;
}

.calc-line {
  margin-left: auto;
  color: var(--accent);
  font-weight: 800;
}

.rx-summary-row {
  display: flex;
  justify-content: flex-end;
  min-width: 1036px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: #f0fbf3;
}

.rx-table {
  overflow-x: visible;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: white;
  min-width: 1036px;
}

.rx-row {
  display: grid;
  grid-template-columns: 28px 34px minmax(150px, 1.2fr) minmax(96px, 0.8fr) 140px 54px 62px 52px minmax(56px, 0.45fr) 70px 70px;
  gap: 0;
  min-width: 1036px;
}

.rx-form .save-rx {
  width: 150px;
  min-width: 150px;
}

.rx-form .rx-toolbar .rx-action-equal {
  width: 144px;
  min-width: 144px;
}

.rx-row.header {
  color: #334e55;
  font-weight: 800;
  background: #eef5ef;
}

.rx-row > * {
  min-height: 34px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  padding: 5px;
}

.rx-row > *:last-child {
  border-right: 0;
}

.rx-row.active {
  background: #d5eaff;
}

.rx-row.selected-line {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.rx-form.locked .rx-row.active {
  background: #f3f7f4;
}

.rx-form.locked input:disabled,
.rx-form.locked select:disabled,
.rx-form.locked button:disabled,
.note-box textarea:disabled {
  color: #667b75;
  background: #edf3ef;
  cursor: not-allowed;
  opacity: 1;
}

.rx-empty {
  min-width: 1160px;
  padding: 16px;
  color: var(--muted);
  background: white;
}

.row-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c12118;
  background: #fff6f4;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.row-delete:hover {
  color: white;
  background: #c12118;
}

.group-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: #1683d8;
  font-weight: 800;
}

.medicine-cell {
  text-align: left;
  color: var(--ink);
  background: transparent;
}

.dose-cell {
  display: grid;
  grid-template-columns: 22px 1fr 22px;
  gap: 1px;
  padding: 3px;
}

.dose-cell button {
  border: 0;
  border-radius: 5px;
  color: var(--bad);
  background: #fff5f3;
  font-weight: 900;
}

.dose-cell input {
  min-height: 30px;
}

.save-rx {
  justify-self: start;
  min-width: 120px;
  padding-left: 18px;
  padding-right: 18px;
}

.action-card {
  display: none;
  gap: 4px;
}

.action-card.open {
  position: fixed;
  top: 64px;
  right: 12px;
  z-index: 20;
  display: grid;
  width: min(380px, calc(100vw - 24px));
  max-height: calc(100vh - 82px);
  overflow: auto;
}

.action-card[data-mode="charge"] #dispense-form,
.action-card[data-mode="dispense"] #charge-form,
.action-card[data-mode="dispense"] #charge-preview {
  display: none;
}

.selected-rx {
  display: grid;
  gap: 2px;
  padding: 9px;
  border: 1px solid #cfe6df;
  border-radius: 9px;
  background: #eefaf7;
}

.selected-rx strong {
  color: var(--accent);
  font-size: 27px;
}

.action-form,
.mini-form,
.search-bar,
.picker-search {
  display: grid;
  gap: var(--gap);
}

.action-form {
  grid-template-columns: 1fr 1fr;
}

.action-form button,
.action-form select,
.action-form input {
  min-height: 34px;
}

.billing-preview {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #cfe6df;
  border-radius: 8px;
  background: #f8fcfb;
  color: var(--muted);
  font-size: 13px;
}

.billing-preview.has-data {
  color: var(--ink);
}

.billing-preview-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.billing-preview-summary strong {
  color: var(--accent);
}

.billing-preview-summary small,
.billing-preview-empty {
  color: var(--muted);
}

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

.billing-preview-table th,
.billing-preview-table td {
  padding: 5px 4px;
  border-top: 1px solid #dcebe7;
  text-align: left;
  overflow-wrap: anywhere;
}

.billing-preview-table th:nth-child(1),
.billing-preview-table td:nth-child(1) {
  width: 58px;
}

.billing-preview-table th:nth-child(4),
.billing-preview-table td:nth-child(4),
.billing-preview-table th:nth-child(5),
.billing-preview-table td:nth-child(5),
.billing-preview-table th:nth-child(6),
.billing-preview-table td:nth-child(6) {
  width: 58px;
  text-align: right;
}

.tight {
  margin-top: 0;
}

.medicine-hint {
  display: grid;
  gap: 2px;
  min-height: 86px;
  padding: 6px 2px 0;
  color: var(--muted);
}

.medicine-hint strong {
  color: var(--ink);
}

.status-line {
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid #ccebdc;
  border-radius: 9px;
  background: #f1fff8;
  color: var(--ok);
}

.status-line[data-tone="bad"] {
  border-color: #f4c7c3;
  background: #fff5f3;
  color: var(--bad);
}

.pill[data-tone="ok"] {
  border-color: #b8dfc7;
  color: var(--ok);
  background: #ecfff5;
}

.pill[data-tone="bad"] {
  border-color: #f4c7c3;
  color: var(--bad);
  background: #fff5f3;
}

.btn {
  min-height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 5px 11px;
  color: var(--accent-strong);
  background: white;
  font-weight: 800;
}

.btn.primary {
  border-color: var(--accent);
  color: white;
  background: var(--accent);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.8);
}

.btn.success {
  border-color: var(--ok);
  color: white;
  background: var(--ok);
}

.btn.danger {
  border-color: #f3b4ae;
  color: var(--bad);
  background: #fff0ee;
}

dialog {
  border: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
}

dialog::backdrop {
  background: rgba(17, 35, 38, 0.34);
  backdrop-filter: blur(2px);
}

.page-dialog,
.medicine-dialog {
  width: min(1220px, calc(100vw - 28px));
  max-height: calc(100vh - 26px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 24px 80px rgba(17, 35, 38, 0.22);
  overflow: hidden;
}

.page-dialog.narrow {
  width: min(860px, calc(100vw - 28px));
}

.emr-template-dialog {
  width: min(1180px, calc(100vw - 28px));
}

.emr-template-summary {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  font-size: 13px;
}

.emr-template-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 8px;
  max-height: calc(100vh - 196px);
  padding: 10px;
  overflow: auto;
  background: #f5faf7;
}

.emr-template-card {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  box-shadow: 0 8px 18px rgba(17, 35, 38, 0.05);
}

.emr-template-card h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
}

.emr-template-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.emr-template-options button {
  min-height: 30px;
  max-width: 100%;
  border: 1px solid #d4e3dd;
  border-radius: 7px;
  padding: 5px 8px;
  color: #244c49;
  background: #fbfefd;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
}

.emr-template-options button:hover,
.emr-template-options button:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.emr-template-options button.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.emr-template-options button span {
  overflow-wrap: anywhere;
}

.emr-template-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 9px 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  background: #f7fbf8;
}

.dialog-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.dialog-search {
  width: min(360px, 42vw);
  min-width: 220px;
  height: 30px;
}

.cashier-pay-dialog {
  width: min(520px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 24px 80px rgba(17, 35, 38, 0.22);
  overflow: hidden;
}

.cashier-pay-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.cashier-pay-summary {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.cashier-pay-summary strong {
  color: var(--accent);
  font-size: 24px;
}

.cashier-pay-summary span {
  overflow-wrap: anywhere;
}

.cashier-pay-qr-frame {
  display: grid;
  place-items: center;
  width: min(320px, 78vw);
  aspect-ratio: 1;
  margin: 0 auto;
  border: 1px solid #cfe6df;
  border-radius: 8px;
  background: #fff;
}

.cashier-pay-qr-frame img {
  width: min(300px, 74vw);
  height: min(300px, 74vw);
  object-fit: contain;
}

.cashier-pay-qr-frame span,
.cashier-pay-status {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.cashier-pay-status[data-status="settled"] {
  color: var(--accent);
  font-weight: 700;
}

.cashier-pay-status[data-status="paid_his_failed"],
.cashier-pay-status[data-status="failed"],
.cashier-pay-status[data-status="closed"] {
  color: #9d2f24;
  font-weight: 700;
}

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

.medicine-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.medicine-cabinet-store-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.medicine-cabinet-store-select {
  min-width: 170px;
  max-width: 260px;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

.search-bar {
  grid-template-columns: 125px 140px 160px minmax(170px, 1fr) 120px 120px;
  align-items: end;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: #f3f8f4;
}

.query-table {
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding: 5px;
}

.query-table table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.query-table th,
.query-table td {
  border-bottom: 1px solid var(--line);
  padding: 5px 6px;
  text-align: left;
  white-space: nowrap;
}

.query-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #354c50;
  background: #e8f1ec;
}

.query-table tbody tr {
  cursor: pointer;
}

.query-table tbody tr:hover,
.query-table tbody tr.selected {
  background: #d8f6cf;
}

.query-table tbody tr.unmatched {
  color: #69797d;
  background: #f7f8f3;
  cursor: not-allowed;
}

.query-table td small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.finance-dialog {
  width: min(1380px, calc(100vw - 28px));
}

.finance-search {
  grid-template-columns: 130px 130px 220px 150px minmax(180px, 1fr) 92px 110px;
}

.finance-summary {
  display: grid;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: #fbfdfb;
}

.finance-metrics {
  display: grid;
  grid-template-columns: repeat(8, minmax(96px, 1fr));
  gap: 8px;
}

.finance-metric {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

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

.finance-metric strong {
  color: var(--accent);
  font-size: 18px;
}

.finance-groups {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 8px;
}

.finance-groups section {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.finance-groups p {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0 0;
  color: var(--muted);
}

.finance-groups p span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finance-groups p b {
  color: var(--ink);
}

.finance-import-panel {
  display: grid;
  grid-template-columns: 140px 220px minmax(360px, 1fr) 110px;
  gap: 8px;
  align-items: end;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.finance-import-panel[hidden] {
  display: none;
}

.finance-import-panel textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
}

.finance-row-exception {
  color: #8d2d22;
  background: #fff6f4;
}

.match-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.match-chip.ok {
  color: var(--ok);
  background: #e6f8ee;
}

.match-chip.bad {
  color: var(--bad);
  background: #fff0ee;
}

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

.two-forms {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 7px;
}

.mini-form {
  grid-template-columns: 1fr 1fr;
  align-content: start;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8faf6;
}

.mini-form strong,
.mini-form .wide {
  grid-column: 1 / -1;
}

.medicine-dialog {
  width: min(1220px, calc(100vw - 20px));
}

.pharmacy-doc-dialog {
  width: min(1180px, calc(100vw - 24px));
}

.pharmacy-doc-search {
  display: grid;
  grid-template-columns: 150px 150px 180px minmax(190px, 1fr) minmax(190px, 1fr) auto auto;
  align-items: end;
  gap: 6px;
  padding: 7px;
  border-bottom: 1px solid var(--line);
  background: #f3f8f4;
}

.pharmacy-doc-search label {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.pharmacy-doc-query-table {
  max-height: min(560px, calc(100vh - 180px));
}

.picker-line-qty,
.bill-line-qty {
  width: 92px;
  min-height: 28px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  font-weight: 800;
  background: #fff;
}

.medicine-picker {
  display: grid;
  grid-template-columns: 265px minmax(0, 1fr);
  height: min(640px, calc(100vh - 92px));
  min-height: 420px;
}

.medicine-tree {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 8px;
  border-right: 1px solid var(--line);
  background: #f8faf6;
}

.medicine-tree button {
  border: 0;
  border-radius: 7px;
  padding: 7px 8px 7px 22px;
  text-align: left;
  background: transparent;
}

.medicine-tree button::before {
  content: "└";
  margin-right: 6px;
  color: var(--muted);
}

.medicine-tree button.active {
  color: var(--accent-strong);
  background: #d8f6cf;
  font-weight: 900;
}

.cabinet-picker-panel {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #c7dfd9;
  border-radius: 10px;
  background: #f2fbf8;
}

.cabinet-picker-device {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.cabinet-picker-device input,
.cabinet-picker-device select {
  min-height: 30px;
  width: 100%;
}

.cabinet-refresh-devices {
  border: 1px solid #8ecdc2 !important;
  border-radius: 8px !important;
  padding: 6px 8px !important;
  background: #fff !important;
  color: var(--accent-strong);
  font-weight: 900;
  text-align: center !important;
}

.cabinet-import-medicines {
  background: var(--accent-strong) !important;
  color: #fff !important;
}

.cabinet-refresh-devices:disabled {
  cursor: wait;
  opacity: 0.7;
}

.cabinet-refresh-devices::before {
  content: "" !important;
  margin: 0 !important;
}

.cabinet-device-summary {
  color: var(--muted);
  line-height: 1.35;
}

.cabinet-device-summary[data-tone="ok"] {
  color: var(--accent-strong);
}

.cabinet-device-summary[data-tone="bad"] {
  color: #b91c1c;
}

.medicine-main {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
  min-width: 0;
}

.medicine-table {
  max-height: none;
  min-height: 0;
  overflow: auto;
}

.picker-search {
  grid-template-columns: 1fr 160px 90px 90px 90px;
  align-items: end;
  padding: 7px;
  border-top: 1px solid var(--line);
  background: #f3f8f4;
}

.pick-check {
  min-height: auto;
  width: 16px;
}

.cabinet-test-body {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(13, 118, 108, 0.08), transparent 32%),
    linear-gradient(315deg, rgba(39, 90, 122, 0.08), transparent 36%),
    var(--bg);
}

.cabinet-test-shell {
  display: grid;
  gap: 10px;
  width: min(1320px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 16px 0;
}

.cabinet-test-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(251, 252, 248, 0.96);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.cabinet-test-head,
.cabinet-test-form {
  padding: 10px;
}

.cabinet-test-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: #f7fbf8;
}

.cabinet-test-head h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.cabinet-test-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.25fr) 160px minmax(220px, 1fr) 160px auto auto;
  gap: 8px;
  align-items: end;
}

.cabinet-test-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.6fr);
  gap: 10px;
}

.cabinet-test-table {
  max-height: 420px;
}

.cabinet-test-table .btn.mini {
  min-height: 24px;
  padding: 2px 8px;
}

.cabinet-raw-output {
  max-height: 260px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  color: #23363a;
  background: #f8faf6;
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.5;
}

.result-dialog {
  width: min(520px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: transparent;
  overflow: visible;
}

.result-dialog::backdrop {
  background: rgba(8, 24, 26, 0.42);
  backdrop-filter: blur(5px);
}

.result-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  box-sizing: border-box;
  max-width: 100%;
  padding: 22px;
  border: 1px solid rgba(174, 196, 186, 0.95);
  border-radius: 18px;
  background:
    radial-gradient(circle at 0 0, rgba(13, 118, 108, 0.12), transparent 36%),
    #fbfcf8;
  box-shadow: 0 24px 70px rgba(8, 24, 26, 0.28);
}

.result-card .btn {
  white-space: nowrap;
}

.result-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  font-size: 28px;
  font-weight: 900;
}

.result-dialog[data-tone="ok"] .result-icon,
.result-icon.signed {
  background: var(--accent);
}

.result-dialog[data-tone="bad"] .result-icon {
  background: var(--bad);
}

.result-copy {
  min-width: 0;
}

.result-copy h2 {
  margin: 3px 0 0;
  font-size: 21px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.result-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 14px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.result-details div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

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

.result-details strong {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
}

.medical-chip {
  color: #075d54;
  border-color: #80c8b7;
  background: #e1f7ef;
}

@media (max-width: 640px) {
  .result-details {
    grid-template-columns: 1fr;
  }

  .dialog-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .dialog-head-actions {
    width: 100%;
  }

  .dialog-search {
    flex: 1;
    min-width: 0;
  }

  .result-card {
    grid-template-columns: 52px minmax(0, 1fr);
    padding: 18px;
  }

  .result-card .btn,
  .result-card .result-link {
    grid-column: 2;
    justify-self: start;
  }
}

.pin-dialog {
  width: min(560px, calc(100vw - 28px));
}

.pin-card {
  grid-template-columns: 58px 1fr;
}

.dialog-note {
  margin: 5px 0 10px;
  color: var(--muted);
}

#signature-pin {
  width: 100%;
}

.pin-error {
  display: block;
  min-height: 20px;
  margin-top: 5px;
  color: var(--bad);
  font-weight: 800;
}

.dialog-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.result-link {
  text-decoration: none;
}

.mobile-patient-dialog {
  width: min(860px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
}

.mobile-patient-detail {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.mobile-queue-layout {
  display: grid;
  grid-template-columns: minmax(340px, 1.15fr) minmax(320px, 0.85fr);
  gap: 12px;
}

.mobile-queue-panel,
.mobile-current-patient-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(251, 252, 248, 0.92);
}

.mobile-dialog-queue-list {
  display: grid;
  gap: 8px;
  max-height: 560px;
  overflow: auto;
}

.mobile-dialog-queue-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.mobile-dialog-queue-item.first {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 133, 116, 0.1);
}

.mobile-dialog-queue-item.active {
  background: rgba(15, 133, 116, 0.08);
}

.mobile-dialog-queue-item strong,
.mobile-dialog-queue-item span,
.mobile-dialog-queue-item small {
  display: block;
  overflow-wrap: anywhere;
}

.queue-rank {
  display: grid;
  place-items: center;
  min-height: 36px;
  border-radius: 10px;
  background: rgba(15, 133, 116, 0.1);
  color: var(--accent);
  font-weight: 900;
}

.mobile-dialog-tip {
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 800;
}

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

.mobile-patient-summary > div,
.mobile-patient-symptom,
.mobile-history-list article {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fbfcf8;
}

.mobile-patient-summary b {
  display: block;
  color: var(--ink);
  font-size: 20px;
}

.mobile-patient-summary small,
.mobile-history-list small {
  color: var(--muted);
  font-weight: 800;
}

.mobile-patient-summary strong,
.mobile-patient-summary span {
  display: block;
  overflow-wrap: anywhere;
}

.mobile-patient-symptom p,
.mobile-history-list p {
  margin: 4px 0;
}

.mobile-history-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
}

.mobile-history-list article > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

@media (max-width: 760px) {
  .mobile-queue-layout {
    grid-template-columns: 1fr;
  }

  .mobile-patient-summary {
    grid-template-columns: 1fr;
  }
}

.seal-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 12px;
}

.seal-form .wide {
  grid-column: 1 / -1;
}

.seal-form label {
  color: var(--muted);
  font-weight: 800;
}

.seal-preview {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  width: 158px;
  height: 158px;
  justify-self: center;
  margin: 4px 0;
  border: 4px solid #b42318;
  border-radius: 50%;
  color: #b42318;
  font-size: 20px;
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.12em;
  transform: rotate(-10deg);
  background: rgba(255, 255, 255, 0.82);
}

.seal-preview.has-image {
  width: 220px;
  height: 140px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  transform: none;
  letter-spacing: 0;
}

.seal-form input[type="file"] {
  padding: 5px;
  background: #fff;
}

.master-data-dialog {
  width: 100%;
  min-height: calc(100vh - 64px);
}

.master-data-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  height: calc(100vh - 126px);
  min-height: 520px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 12px 12px;
  background: var(--paper);
}

.master-tabs {
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 8px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #e6f0eb, #f8faf6);
}

.master-tabs button {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 10px;
  color: var(--accent-strong);
  text-align: left;
  background: transparent;
  font-weight: 900;
}

.master-tabs button.active {
  border-color: var(--accent);
  color: white;
  background: var(--accent);
}

.master-data-content {
  min-width: 0;
  overflow: auto;
  padding: 8px;
}

.master-panel-title {
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--accent-strong);
  background: #eefaf7;
  font-size: 20px;
  font-weight: 900;
}

.master-form,
.dict-grid {
  display: grid;
  gap: 7px;
}

.clinic-form {
  grid-template-columns: 140px minmax(280px, 1fr);
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #f8faf6;
}

.clinic-form .master-panel-title,
.clinic-form button {
  grid-column: 1 / -1;
}

.clinic-pharmacy-field {
  grid-column: 2 / -1;
}

.clinic-pharmacy-field small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.clinic-cabinet-card {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fcfa;
  padding: 10px;
}

.clinic-cabinet-card.muted {
  color: var(--muted);
}

.clinic-cabinet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.clinic-cabinet-head strong {
  display: block;
  font-size: 15px;
}

.clinic-cabinet-head small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  line-height: 1.35;
}

.clinic-cabinet-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.clinic-cabinet-rows {
  display: grid;
  gap: 6px;
}

.clinic-cabinet-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.35fr) minmax(150px, 1fr) 72px 58px 58px minmax(140px, 1fr) 58px;
  align-items: end;
  gap: 6px;
  padding: 8px;
  border: 1px solid #d7e4df;
  border-radius: 7px;
  background: #fff;
}

.clinic-cabinet-row label {
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
}

.clinic-cabinet-row input,
.clinic-cabinet-row select {
  height: 34px;
  min-height: 34px;
  margin-top: 2px;
  font-size: 14px;
}

.clinic-cabinet-row .clinic-cabinet-check {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 34px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fcfa;
  color: var(--text);
}

.clinic-cabinet-row .clinic-cabinet-check input {
  width: 14px;
  height: 14px;
  min-height: 14px;
  margin: 0;
}

.clinic-cabinet-row .btn.mini {
  min-width: 0;
  height: 34px;
  padding: 0 8px;
}

@media (max-width: 1180px) {
  .clinic-cabinet-row {
    grid-template-columns: minmax(180px, 1fr) minmax(150px, 1fr) 72px 58px 58px;
  }

  .clinic-cabinet-remark {
    grid-column: 1 / -2;
  }
}

@media (max-width: 760px) {
  .clinic-cabinet-head {
    flex-direction: column;
  }

  .clinic-cabinet-row {
    grid-template-columns: 1fr 1fr;
  }

  .clinic-cabinet-store,
  .clinic-cabinet-remark {
    grid-column: 1 / -1;
  }
}

.clinic-seal-box {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 260px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: #eefaf7;
}

.clinic-seal-box p {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.clinic-seal-box input[type="file"] {
  width: 100%;
  margin-bottom: 7px;
  padding: 5px;
  background: white;
}

.hospital-seal-preview {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--muted);
  background: white;
  font-weight: 800;
}

.hospital-seal-preview.has-image {
  color: transparent;
}

.master-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 7px;
}

.master-toolbar.compact {
  align-items: center;
}

.clinic-maintenance,
.legacy-maintenance {
  display: grid;
  gap: 8px;
}

.clinic-maintenance {
  grid-template-columns: minmax(260px, 0.28fr) minmax(520px, 0.72fr);
}

.clinic-list {
  min-width: 0;
}

.select-list {
  display: grid;
  gap: 5px;
  max-height: calc(100vh - 260px);
  overflow: auto;
}

.select-list button {
  display: grid;
  gap: 3px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  text-align: left;
  background: #fffefa;
}

.select-list button.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

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

.select-list button.active span {
  color: #dff8ef;
}

.password-cell,
.row-actions,
.legacy-selector {
  display: flex;
  align-items: center;
  gap: 5px;
}

.password-cell input {
  min-width: 120px;
}

.btn.mini {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 14px;
}

.legacy-selector {
  flex-wrap: wrap;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8faf6;
}

.legacy-selector label {
  min-width: 220px;
}

.legacy-editor {
  max-height: calc(100vh - 280px);
}

.medicine-master-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.36fr) minmax(680px, 0.64fr);
  gap: 8px;
  min-height: 0;
}

.medicine-master-list {
  display: grid;
  gap: 6px;
  align-content: start;
  min-width: 0;
}

.medicine-master-tools,
.medicine-form-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.medicine-master-tools input {
  flex: 1;
}

.medicine-master-table {
  max-height: calc(100vh - 330px);
}

.medicine-master-table tr {
  cursor: pointer;
}

.medicine-master-table tr.active td {
  background: #c8f7cb;
}

.medicine-record-form {
  display: grid;
  gap: 0;
  border: 1px solid #7fb3dd;
  border-radius: 4px;
  overflow: hidden;
  background: #a8cef0;
}

.medicine-form-toolbar {
  padding: 5px;
  background: linear-gradient(#f5f4ed, #d9d7ce);
  border-bottom: 1px solid #8d8d8d;
}

.medicine-form-section {
  display: grid;
  grid-template-columns: repeat(6, minmax(96px, 1fr));
  gap: 5px 8px;
  padding: 8px 10px;
  border-bottom: 2px solid #174dff;
}

.medicine-form-section.bottom {
  border-bottom: 0;
}

.medicine-form-section label {
  display: grid;
  gap: 2px;
  color: #123049;
  font-weight: 800;
  font-size: 15px;
}

.medicine-form-section input,
.medicine-form-section select,
.medicine-form-section textarea {
  min-height: 29px;
  border-color: #9fc5df;
  border-radius: 2px;
  background: #fff;
  font-size: 16px;
}

.medicine-form-section textarea {
  min-height: 86px;
  resize: vertical;
}

.medicine-form-section .wide {
  grid-column: 1 / -1;
}

.radio-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 29px;
}

.radio-line label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 700;
}

.master-table {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
}

.master-table table {
  width: 100%;
  border-collapse: collapse;
}

.master-table th,
.master-table td {
  border-bottom: 1px solid var(--line);
  padding: 4px 5px;
  text-align: left;
  white-space: nowrap;
}

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

.master-table input,
.master-table select,
.master-table textarea {
  min-width: 110px;
  min-height: 30px;
}

.legacy-editor table {
  table-layout: fixed;
  min-width: 820px;
}

.legacy-editor th,
.legacy-editor td {
  padding: 3px 4px;
}

.legacy-editor input,
.legacy-editor select,
.legacy-editor textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 28px;
  padding: 3px 6px;
}

.legacy-editor .row-actions {
  gap: 4px;
}

.legacy-editor .btn.mini {
  min-height: 28px;
  padding: 3px 7px;
}

.role-permission-panel {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfefb 0%, #f1f8f4 100%);
}

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

.role-permission-head strong {
  display: block;
  color: var(--accent-strong);
  font-size: 1.05rem;
}

.role-permission-head small,
.role-permission-table small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.role-permission-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.role-permission-table {
  overflow: auto;
  max-height: 420px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.role-permission-table table {
  width: 100%;
  border-collapse: collapse;
}

.role-permission-table th,
.role-permission-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  white-space: nowrap;
}

.role-permission-table th:first-child,
.role-permission-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 210px;
  text-align: left;
  background: #fff;
}

.role-permission-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #e8f1ec;
}

.role-permission-table th:first-child {
  z-index: 3;
  background: #e8f1ec;
}

.dict-grid {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.dict-grid label {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8faf6;
}

.dict-grid textarea {
  min-height: 220px;
}

.dict-grid button {
  grid-column: 1 / -1;
  justify-self: start;
}

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

.seal-master-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.55fr) minmax(420px, 0.45fr);
  gap: 10px;
}

.inline-seal-form {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8faf6;
}

.legacy-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8faf6;
}

.legacy-panel h3 {
  margin: 0;
  padding: 8px;
  color: var(--accent-strong);
  border-bottom: 1px solid var(--line);
}

.master-table.small {
  max-height: 260px;
  border: 0;
  border-radius: 0 0 10px 10px;
}

.payment-gateway-link-state {
  min-height: 16px;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.3;
}

.payment-gateway-link-state.ok {
  color: #147a46;
}

.payment-gateway-link-state.bad {
  color: #b42318;
}

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

.relationship-list article,
.relationship-list.compact {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8faf6;
}

.relationship-list h3,
.relationship-list p {
  margin: 3px 0;
}

.flow-diagram {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  background: #eefaf7;
}

.flow-diagram span {
  padding: 8px 10px;
  border-radius: 999px;
  color: white;
  background: var(--accent);
  font-weight: 900;
}

.qfbj-body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: #eef4f1;
}

.qfbj-shell {
  display: grid;
  gap: 10px;
  width: min(1680px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 12px 0 18px;
}

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

.qfbj-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.qfbj-topbar h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
}

.qfbj-status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.qfbj-login-panel {
  padding: 10px;
}

.qfbj-login-form,
.qfbj-config-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 8px;
  align-items: end;
}

.qfbj-login-form label,
.qfbj-config-grid label,
.qfbj-editor-grid label {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-weight: 800;
}

.qfbj-login-form input,
.qfbj-config-grid input,
.qfbj-editor-grid textarea {
  width: 100%;
  min-width: 0;
}

.qfbj-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
}

.qfbj-sidebar,
.qfbj-main {
  min-width: 0;
  padding: 10px;
}

.qfbj-endpoint-list {
  display: grid;
  gap: 6px;
  max-height: calc(100vh - 290px);
  overflow: auto;
}

.qfbj-endpoint-list button {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.qfbj-endpoint-list button.active {
  border-color: var(--accent);
  background: #e7f7f3;
}

.qfbj-endpoint-list small,
.qfbj-selected-path {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.qfbj-check {
  display: inline-flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.qfbj-check input {
  width: auto;
}

.qfbj-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 0;
}

.qfbj-editor-head > div:first-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.qfbj-editor-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.48fr) minmax(420px, 0.52fr);
  gap: 10px;
  min-height: 0;
}

.qfbj-editor-grid textarea,
.qfbj-output {
  min-height: 520px;
  max-height: calc(100vh - 310px);
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.45;
  overflow: auto;
  white-space: pre;
}

.qfbj-test-results {
  overflow: auto;
}

.qfbj-test-results table {
  width: 100%;
  border-collapse: collapse;
}

.qfbj-test-results th,
.qfbj-test-results td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.qfbj-test-results td:last-child {
  white-space: normal;
}

@media (max-width: 900px) {
  .qfbj-layout,
  .qfbj-editor-grid,
  .qfbj-login-form,
  .qfbj-config-grid,
  .finance-search,
  .finance-import-panel,
  .finance-metrics,
  .finance-groups {
    grid-template-columns: 1fr;
  }

  .qfbj-editor-head,
  .qfbj-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .qfbj-editor-grid textarea,
  .qfbj-output {
    min-height: 340px;
    max-height: none;
  }
}

@media (max-width: 1120px) {
  .topbar {
    align-items: flex-start;
  }

  .brand {
    min-width: 0;
    flex: 1;
    gap: 8px;
  }

  .brand h1 {
    font-size: 22px;
  }

  .brand-clock {
    min-width: auto;
    margin-bottom: 0;
  }

  .doctor-grid,
  .two-forms,
  .medicine-picker,
  .master-data-layout,
  .legacy-grid,
  .role-card-grid,
  .seal-master-grid,
  .emr-ai-strip {
    grid-template-columns: 1fr;
  }

  .video-sidebar {
    position: relative;
    top: auto;
    height: calc(100vh - 92px);
    min-height: 560px;
  }

  .video-stage {
    grid-template-rows: minmax(280px, 1.2fr) minmax(240px, 0.9fr);
  }

  .patient-video-grid,
  .patient-video-actions {
    grid-template-columns: 1fr;
  }

  .rx-head,
  .note-grid,
  .search-bar,
  .picker-search,
  .dict-grid,
  .clinic-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-install-card,
  .mobile-install-permissions,
  .mobile-install-actions {
    grid-template-columns: 1fr;
  }

  .mobile-install-mark {
    width: 50px;
    height: 50px;
    border-radius: 16px;
  }

  .medicine-tree {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
