:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --line: #d8dde3;
  --text: #18212b;
  --muted: #65717f;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1440px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  letter-spacing: 0;
}

[v-cloak] {
  display: none;
}

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

button,
.ghost-link {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  gap: 18px;
}

.login-panel h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.login-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.login-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.login-field input,
.login-field select {
  height: 42px;
  padding: 0 12px;
  color: var(--text);
  font-size: 15px;
}

.account-loading {
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
}

.login-submit {
  height: 42px;
  font-size: 15px;
}

.topbar {
  height: 86px;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions,
.button-row,
.preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-switcher {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
}

.account-switcher select {
  min-width: 120px;
  height: 36px;
  padding: 0 8px;
  color: var(--text);
  font-size: 13px;
}

.account-login {
  display: flex;
  align-items: center;
  gap: 6px;
}

.account-login input {
  width: 120px;
  height: 36px;
  padding: 0 8px;
  color: var(--text);
  font-size: 13px;
}

.account-login button {
  height: 36px;
  padding: 0 10px;
  font-size: 13px;
}

.account-badge {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  font-size: 13px;
}

.compact-input {
  width: 180px;
  height: 36px;
  padding: 0 10px;
}

.workspace {
  display: grid;
  grid-template-columns: 220px minmax(500px, 0.8fr) minmax(720px, 1.2fr);
  align-items: start;
  min-height: calc(100vh - 86px);
}

.project-panel {
  border-right: 1px solid var(--line);
  background: #e7ebef;
  padding: 10px;
  font-size: 12px;
}

.panel-title {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.project-editor {
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
}

.project-editor label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.project-editor input {
  height: 32px;
  padding: 0 8px;
  color: var(--text);
  font-size: 12px;
}

.project-editor button {
  height: 32px;
  font-size: 12px;
}

.project-item {
  width: 100%;
  height: 34px;
  margin-bottom: 6px;
  background: transparent;
  padding: 0 8px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 24px;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

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

.project-item.active {
  border-color: var(--accent);
  background: #d9f3ef;
}

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

.project-delete {
  width: 22px;
  height: 22px;
  min-width: 22px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--danger);
  font-size: 12px;
  line-height: 1;
}

.project-delete:hover {
  border-color: #fecaca;
  background: #fef2f2;
}

.main-grid {
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(580px, 1fr);
  grid-auto-rows: min-content;
  gap: 16px;
}

.preview-band,
.tool-surface {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.preview-band {
  padding: 14px;
}

.preview-meta,
.section-heading {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.preview-meta strong,
.section-heading h2 {
  font-size: 16px;
  margin: 0;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.preview-meta span {
  margin-left: 10px;
  color: var(--muted);
  font-size: 13px;
}

.preview-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.nameplate-preview {
  margin-top: 12px;
  width: 100%;
  border-radius: 6px;
  background-image:
    linear-gradient(45deg, rgba(0, 0, 0, 0.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0, 0, 0, 0.05) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0, 0, 0, 0.05) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(0, 0, 0, 0.05) 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  overflow: hidden;
}

.nameplate-preview-inner {
  width: 100%;
  height: 100%;
  border: 3px solid #111827;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.nameplate-preview img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: fill;
  display: block;
}

.tool-surface {
  padding: 16px;
}

.participant-list-panel {
  position: sticky;
  top: 18px;
  align-self: start;
  max-height: calc(100vh - 122px);
  margin: 18px 0 18px 14px;
  overflow: auto;
}

.paste-area {
  width: 100%;
  height: 166px;
  margin: 10px 0 10px;
  padding: 10px;
  resize: vertical;
  line-height: 1.5;
}

.status-text {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.notice {
  position: fixed;
  top: 16px;
  right: 18px;
  z-index: 40;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.18);
}

.hint-text {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.local-warning {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  background: #fff7ed;
  color: #7c2d12;
  display: grid;
  gap: 4px;
  font-size: 13px;
  line-height: 1.45;
}

.local-warning strong {
  color: #9a3412;
}

.participant-table {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.participant-row {
  min-height: 68px;
  padding: 6px 8px;
  display: grid;
  grid-template-columns: 22px 54px 34px minmax(0, 1fr) 64px;
  align-items: start;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  font-size: 13px;
  content-visibility: auto;
  contain-intrinsic-size: 68px;
}

.participant-row:last-child {
  border-bottom: 0;
}

.participant-row:hover {
  background: #f8fbfb;
}

.participant-row.active {
  background: #e0f5f1;
  box-shadow: inset 3px 0 0 var(--accent);
}

.participant-row input,
.participant-row textarea,
.participant-row button,
.participant-row a {
  cursor: auto;
}

.person-name {
  font-weight: 700;
  font-size: 13px;
}

.person-title {
  color: var(--muted);
  font-size: 12px;
}

.person-name,
.person-title {
  padding-top: 12px;
}

.person-hospital-editor {
  min-height: 56px;
  padding: 7px 8px;
  line-height: 1.35;
  resize: vertical;
  font-size: 13px;
}

.participant-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-top: 10px;
}

.participant-row a,
.participant-row .text-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-decoration: none;
  line-height: 30px;
  font-size: 12px;
}

.rule-sections {
  margin-top: 14px;
  display: grid;
  gap: 14px;
}

.rule-group {
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
}

.rule-group:first-child {
  padding-top: 0;
  border-top: 0;
}

.rule-group-primary {
  padding: 12px;
  border: 1px solid #b6ddd8;
  border-radius: 8px;
  background: #f3fbfa;
}

.rule-group-heading {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}

.rule-group-heading h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.3;
}

.rule-group-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.rule-step {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.rule-group-primary .rule-step {
  background: var(--accent);
  color: #fff;
}

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

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

.rule-grid .checkbox-label {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.rule-pair {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(120px, 0.8fr);
  gap: 10px;
}

.rule-pair.compact {
  grid-column: 1 / -1;
  align-items: end;
}

.rule-grid input,
.rule-grid select {
  height: 36px;
  padding: 0 10px;
  color: var(--text);
}

.rule-grid .checkbox-label input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.color-control input[type="color"] {
  width: 72px;
  min-width: 72px;
  padding: 4px;
}

code {
  min-height: 36px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
}

.empty-state {
  margin: 64px auto;
  width: 520px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
}

@media (max-width: 900px) {
  body {
    min-width: 0;
  }

  .topbar,
  .workspace,
  .main-grid,
  .rule-grid {
    display: block;
  }

  .rule-grid,
  .rule-pair {
    display: grid;
    grid-template-columns: 1fr;
  }

  .rule-grid label,
  .rule-grid .checkbox-label {
    margin-bottom: 10px;
  }

  .topbar {
    height: auto;
  }

  .topbar-actions,
  .button-row,
  .preview-actions {
    flex-wrap: wrap;
    margin-top: 12px;
  }

  .project-panel,
  .participant-list-panel,
  .tool-surface,
  .preview-band {
    margin-bottom: 12px;
  }

  .participant-list-panel {
    position: static;
    max-height: none;
    margin: 12px;
  }

  .participant-row {
    grid-template-columns: 24px 70px 56px minmax(120px, 1fr);
  }

  .participant-actions {
    grid-column: 4;
    justify-content: flex-start;
    padding-top: 0;
  }
}
