:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #4f46e5;
  --brand-dark: #3730a3;
  --red: #d32f2f;
  --amber: #ef6c00;
  --yellow: #f9a825;
  --green: #2e7d32;
  --grey: #757575;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  line-height: 1.65;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 22px; }

.site-header {
  background: linear-gradient(135deg, #312e81 0%, #4f46e5 55%, #6366f1 100%);
  color: #fff;
  padding: 26px 0 22px;
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 16px; }
.logo {
  width: 54px; height: 54px; border-radius: 14px; background: rgba(255,255,255,.16);
  display: flex; align-items: center; justify-content: center; font-weight: 800; letter-spacing: .5px;
  font-size: 17px; border: 1px solid rgba(255,255,255,.28);
}
.logo span { color: #c7d2fe; }
.site-header h1 { font-size: 21px; margin: 0 0 2px; font-weight: 700; letter-spacing: .2px; }
.site-header .sub { margin: 0; font-size: 12.5px; color: #dbdafe; }
.stats { font-size: 12.5px; color: #e0e7ff; text-align: right; }
.stats b { color: #fff; }

.tabs { display: flex; gap: 6px; margin-top: -1px; padding-top: 16px; }
.tab {
  border: none; background: transparent; padding: 9px 16px; border-radius: 10px 10px 0 0;
  font-size: 14.5px; color: var(--muted); cursor: pointer; font-weight: 600;
}
.tab:hover { color: var(--brand); background: #eef2ff; }
.tab.active { background: var(--card); color: var(--brand-dark); box-shadow: 0 -2px 10px rgba(15,23,42,.05); }

main { padding-bottom: 40px; }
.panel { background: var(--card); border-radius: 0 14px 14px 14px; padding: 26px; box-shadow: 0 8px 28px rgba(15,23,42,.06); }
.panel.hidden { display: none; }
.panel h2 { margin-top: 0; font-size: 19px; }
.panel h3 { font-size: 16px; margin-bottom: 6px; }
.panel ul { padding-left: 22px; }
.warn { background: #fff7ed; border-left: 4px solid var(--amber); padding: 12px 14px; border-radius: 8px; }

/* ---------- pickers ---------- */
.picker-row { display: grid; grid-template-columns: 1fr 44px 1fr; gap: 14px; align-items: start; }
.picker label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; letter-spacing: .4px; }
.input-wrap { position: relative; }
.input-wrap input {
  width: 100%; padding: 13px 14px; font-size: 15px; border: 1.5px solid var(--line); border-radius: 11px;
  outline: none; background: #fbfcfe; transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
.input-wrap input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); background: #fff; }
.dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--line);
  border-radius: 11px; box-shadow: 0 14px 34px rgba(15,23,42,.14); max-height: 320px; overflow-y: auto;
  z-index: 30; display: none;
}
.dropdown.open { display: block; }
.dropdown .item { padding: 9px 13px; cursor: pointer; border-bottom: 1px solid #f3f4f6; }
.dropdown .item:last-child { border-bottom: none; }
.dropdown .item.active, .dropdown .item:hover { background: #eef2ff; }
.dropdown .item .zh { font-weight: 600; }
.dropdown .item .en { font-size: 12.5px; color: var(--muted); }
.dropdown .item .cls { font-size: 11.5px; color: #9ca3af; }
.dropdown .none { padding: 12px 13px; color: var(--muted); font-size: 13px; }
.badge { display: inline-block; font-size: 10.5px; padding: 1px 6px; border-radius: 20px; background: #eef2ff; color: var(--brand-dark); margin-left: 6px; vertical-align: 1px; }
.chosen { margin-top: 8px; font-size: 13.5px; min-height: 22px; color: var(--brand-dark); font-weight: 600; }
.chosen .en { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.swap {
  align-self: center; margin-top: 24px; width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line);
  background: #fff; font-size: 19px; color: var(--brand); cursor: pointer; transition: .15s;
}
.swap:hover { background: #eef2ff; border-color: var(--brand); }

.quick { margin-top: 18px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 5px 12px; font-size: 12.5px;
  color: #374151; cursor: pointer; font-family: inherit;
}
.chip:hover { border-color: var(--brand); color: var(--brand); background: #eef2ff; }

/* ---------- result ---------- */
.result-empty { text-align: center; color: var(--muted); padding: 46px 10px 26px; }
.empty-illustration { font-size: 30px; opacity: .55; margin-bottom: 10px; }
.result-card { margin-top: 24px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.result-head { padding: 18px 22px; color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.result-head .status { font-size: 21px; font-weight: 800; letter-spacing: .5px; }
.result-head .status small { display: block; font-size: 12px; font-weight: 400; opacity: .9; letter-spacing: 0; }
.result-head .pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.35); padding: 3px 10px; border-radius: 20px; font-size: 12px; }
.result-body { padding: 20px 22px 8px; }
.pair-title { font-size: 17px; font-weight: 700; margin: 0 0 2px; }
.pair-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.section { margin-bottom: 16px; }
.section h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 700; letter-spacing: .5px; }
.advice { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.lead { font-size: 15.5px; }
.lead .tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; margin-right: 7px; vertical-align: 1px; }
details { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; background: #fcfcfd; }
details summary { cursor: pointer; font-size: 13.5px; color: var(--brand-dark); font-weight: 600; outline: none; }
details .en-body { margin-top: 10px; font-size: 13.5px; color: #374151; line-height: 1.7; white-space: pre-wrap; }
details .refs { margin-top: 10px; font-size: 12.5px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 22px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: 0; }
.dot.red { background: var(--red); } .dot.amber { background: var(--amber); }
.dot.yellow { background: var(--yellow); } .dot.green { background: var(--green); } .dot.grey { background: var(--grey); }

/* ---------- browse ---------- */
.browse-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.browse-bar select, .browse-bar input {
  padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 9px; font-size: 14px; font-family: inherit;
  background: #fbfcfe; outline: none;
}
.browse-bar select { min-width: 300px; }
.browse-bar input { flex: 1; min-width: 200px; }
.status-filters { display: flex; gap: 6px; }
.sf { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 11px; font-size: 12.5px; cursor: pointer; font-family: inherit; color: #374151; }
.sf.active { border-color: var(--brand); background: #eef2ff; color: var(--brand-dark); font-weight: 600; }
.browse-summary { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.browse-table { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.browse-row { display: grid; grid-template-columns: 24px 1.2fr 1.1fr 1.4fr; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #f1f3f6; font-size: 13.5px; align-items: start; }
.browse-row:last-child { border-bottom: none; }
.browse-row.head { background: #f8fafc; font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: .4px; }
.browse-row .co-zh { font-weight: 600; }
.browse-row .co-en { font-size: 12px; color: var(--muted); }
.browse-row .lead { font-size: 12.8px; color: #4b5563; }
.browse-row .cls { font-size: 11.5px; color: #9ca3af; }
.tag-status { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 20px; color: #fff; white-space: nowrap; }

.site-footer { border-top: 1px solid var(--line); background: #fff; padding: 16px 0; font-size: 12.5px; color: var(--muted); }
@media (max-width: 760px) {
  .picker-row { grid-template-columns: 1fr; }
  .swap { margin: 0 auto; transform: rotate(90deg); }
  .browse-row { grid-template-columns: 22px 1fr; }
  .browse-row .cls, .browse-row .lead { grid-column: 2; }
}

/* ======================= v2: matrix / modal / mobile ======================= */
.offline-badge {
  display: inline-block; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.28);
  padding: 2px 9px; border-radius: 20px; font-size: 11.5px; color: #eef2ff; margin-bottom: 4px;
}
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px 14px;
  font-size: 13.5px; font-family: inherit; cursor: pointer; color: #374151; white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand-dark); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); color: #fff; }
.btn.ghost { background: #fff; }

.matrix-toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.matrix-toolbar h2 { margin: 0 0 4px; font-size: 19px; }
.matrix-toolbar .hint { margin: 0; color: var(--muted); font-size: 12.5px; max-width: 560px; }
.matrix-actions { display: flex; align-items: center; gap: 8px; }
.counter { font-size: 13px; color: var(--muted); background: #f1f5f9; padding: 5px 10px; border-radius: 8px; }

.multi-row { display: grid; grid-template-columns: 1fr 1.35fr; gap: 14px; margin-top: 16px; }
.multi-col { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.multi-head {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 12px;
  background: #f8fafc; border-bottom: 1px solid var(--line); font-size: 13.5px; font-weight: 700;
}
.sel-count { font-weight: 400; font-size: 12px; color: var(--muted); }
.multi-search { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); }
.multi-search input {
  flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; font-family: inherit; outline: none; background: #fbfcfe;
}
.multi-search input:focus { border-color: var(--brand); }
.mini {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px;
  font-size: 12px; cursor: pointer; font-family: inherit; color: #374151;
}
.mini:hover { border-color: var(--brand); color: var(--brand); }
.multi-list { height: 320px; overflow-y: auto; }
.multi-item {
  display: flex; align-items: flex-start; gap: 8px; padding: 7px 11px; border-bottom: 1px solid #f3f4f6;
  font-size: 13px; cursor: pointer;
}
.multi-item:hover { background: #f8fafc; }
.multi-item.on { background: #eef2ff; }
.multi-item input { margin-top: 3px; flex: none; }
.mi-main { line-height: 1.35; }
.mi-main em { display: block; font-style: normal; color: var(--muted); font-size: 11.5px; }
.multi-empty, .matrix-empty { padding: 24px 14px; color: var(--muted); font-size: 13px; text-align: center; }
.badge {
  display: inline-block; font-size: 10px; padding: 0 5px; border-radius: 20px; background: #e0e7ff;
  color: var(--brand-dark); margin-left: 5px; font-style: normal; vertical-align: 1px;
}

.matrix-output { margin-top: 18px; }
.matrix-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.matrix-summary { font-size: 13px; color: #374151; }
.matrix-summary b { font-weight: 700; }
.s-red { color: var(--red); } .s-amber { color: var(--amber); }
.s-yellow { color: #b28704; } .s-green { color: var(--green); }

.matrix-scroll { overflow: auto; max-height: 68vh; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table.matrix { border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.matrix th {
  position: sticky; top: 0; z-index: 2; background: #f8fafc; padding: 8px 6px; font-weight: 600;
  border-bottom: 1px solid var(--line); max-width: 92px; min-width: 54px; font-size: 11.5px;
  white-space: normal; word-break: break-word; line-height: 1.25;
}
table.matrix th.corner { left: 0; z-index: 3; min-width: 120px; }
table.matrix th.rowhead {
  position: sticky; left: 0; z-index: 1; background: #f8fafc; text-align: left; max-width: 170px;
  min-width: 120px; border-right: 1px solid var(--line); font-size: 12px; padding: 8px 10px;
  white-space: normal; word-break: break-word; line-height: 1.3;
}
table.matrix td.cell {
  width: 38px; height: 34px; min-width: 38px; text-align: center; color: #fff; font-weight: 700;
  cursor: pointer; border: 1px solid #fff; font-size: 12.5px;
}
table.matrix td.cell:hover { outline: 2px solid #1f2937; outline-offset: -2px; }
table.matrix td.cell.none { background: #eef0f3; color: #9aa3ad; font-weight: 400; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend .muted { color: #9ca3af; }

.modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal.hidden { display: none; }
.modal-card { background: #fff; border-radius: 16px; width: 100%; max-width: 720px; max-height: 88vh; overflow: auto; position: relative; }
.modal-close {
  position: absolute; top: 10px; right: 12px; width: 34px; height: 34px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.28); color: #fff; font-size: 20px; line-height: 1; cursor: pointer; z-index: 3;
}
.modal-close:hover { background: rgba(255,255,255,.45); }

@media (max-width: 820px) {
  .multi-row { grid-template-columns: 1fr; }
  .multi-list { height: 220px; }
  .matrix-toolbar { flex-direction: column; }
  .matrix-actions { width: 100%; justify-content: space-between; }
  .matrix-actions .btn { flex: 1; }
  .panel { padding: 18px 14px; }
  .site-header h1 { font-size: 18px; }
  .stats { text-align: left; }
  table.matrix th.corner, table.matrix th.rowhead { min-width: 96px; max-width: 120px; font-size: 11px; }
}

/* ======================= v3: full translation ======================= */
.zh-full {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  font-size: 14px; line-height: 1.8; color: #1f2937; white-space: pre-wrap;
}
.zh-full + .zh-full { margin-top: 8px; }

/* ======================= v4: SmPC contraindication note ======================= */
.contra-warn {
  border: 1px solid #f5c2c0; background: #fff5f5; color: #8a1f1a;
  border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.7;
}
.contra-warn b { font-size: 13.5px; }
.contra-sub { margin-top: 6px; color: #9b4a45; font-size: 12.5px; }

/* ======================= v5: FDA label note ======================= */
.label-flag {
  border: 1px solid #bfd8ef; background: #f3f9ff; color: #1b4468;
  border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.7;
}
.label-flag b { font-size: 13.5px; }
.label-sub { margin-top: 6px; color: #4a7396; font-size: 12.5px; }
