:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1d2b30;
  background: #f5f6fa;
  font-size: 14px;
  line-height: 1.6;
  --accent: #3858ce;
  --muted: #626f76;
  --line: #e1e5ed;
  --soft: #f4f6fb;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { touch-action: manipulation; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 1px solid transparent; border-radius: 5px; padding: 8px 14px; min-height: 38px; background: none; color: inherit; font-weight: 500; }
button:disabled { opacity: .45; cursor: not-allowed; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea { border: 1px solid #cbd4d7; border-radius: 5px; background: #fff; color: inherit; padding: 8px 11px; min-width: 0; }
input::placeholder, textarea::placeholder { color: #69777f; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
h1 { font-size: 27px; font-weight: 650; letter-spacing: -.6px; line-height: 1.4; }
h2 { font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; }
.primary { background: var(--accent); color: white; }
.primary:hover:not(:disabled) { background: #2947b7; }
.secondary { background: #fff; border-color: #cbd4d7; }
.secondary:hover:not(:disabled) { background: var(--soft); }
.text-button { color: var(--muted); padding: 6px 9px; }
.right { text-align: right; }
.topbar { min-height: 65px; display: flex; align-items: center; gap: 24px; padding: 0 max(28px, calc((100% - 1224px) / 2)); border-bottom: 1px solid var(--line); background: #fff; }
.brand { display: flex; align-items: center; gap: 12px; color: #25334a; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand strong { font-size: 25px; letter-spacing: -1px; }
.brand-note { font-size: 12px; color: var(--muted); }
.topbar nav { display: flex; align-self: stretch; gap: 22px; margin-right: auto; min-width: 0; overflow-x: auto; }
.topbar nav a { display: flex; align-items: center; padding: 18px 0; border-bottom: 2px solid transparent; font-size: 13px; color: #46546a; white-space: nowrap; }
.topbar nav a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.topbar nav a:hover { text-decoration: none; color: var(--accent); }
.account { display: flex; align-items: center; gap: 9px; white-space: nowrap; font-size: 12px; color: var(--muted); }
.demo-banner { color: #726139; font-size: 11px; background: #faf7ee; border: 1px solid #ebe4d2; border-radius: 4px; padding: 2px 7px; }
main { max-width: 1280px; margin: auto; padding: 29px 28px 36px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; gap: 18px; }
.page-heading h1 { margin: 0 0 6px; }
.count { display: inline-block; vertical-align: middle; font-size: 13px; font-weight: 400; color: var(--muted); letter-spacing: 0; border-left: 1px solid #cdd6d9; padding-left: 13px; margin-left: 13px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.toolbar { padding: 16px 20px; display: flex; align-items: center; gap: 12px; }
.search { display: flex; flex: 1; max-width: 340px; }
.search input { width: 100%; }
.toolbar select { max-width: 280px; }
.toolbar > button { margin-left: auto; }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { font-size: 12px; color: var(--muted); background: #f6f8f8; font-weight: 500; padding: 11px 20px; border-block: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 20px; border-bottom: 1px solid #eaf0f1; white-space: nowrap; font-size: 14px; }
tbody tr:last-child td { border-bottom: 0; }
.customer-table tbody tr:hover { background: #f7f9fe; }
.customer-name { color: #22383c; font-weight: 600; }
.customer-name:hover { color: var(--accent); }
.phone-cell, .created-cell { font-variant-numeric: tabular-nums; }
.phone-cell { letter-spacing: .25px; }
.institution-cell { font-size: 13px; }
.created-cell { color: var(--muted); font-size: 12px; }
.row-actions { display: flex; justify-content: flex-end; align-items: center; gap: 17px; }
.row-actions button, .row-actions a { font-size: 13px; padding: 3px 1px; min-height: 30px; display: inline-flex; align-items: center; }
.row-actions button { color: var(--muted); }
.row-actions button:hover { color: #203c42; text-decoration: underline; }
.table-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding: 13px 20px; gap: 12px; }
.table-footer button { font-size: 12px; padding: 5px 11px; min-height: 32px; margin-left: 8px; }
.empty { padding: 45px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.error { color: #a32d40; font-size: 13px; white-space: pre-wrap; }
.error:empty { display: none; }
.back { font-size: 13px; color: var(--muted); display: inline-block; padding: 0 0 15px; }
.detail-heading { margin-bottom: 25px; align-items: start; }
.detail-heading > button { margin-top: 4px; flex-shrink: 0; }
.profile { min-width: 0; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 8px 25px; margin: 12px 0 0; font-size: 13px; }
.profile-meta > div { display: flex; gap: 9px; }
.profile-meta dt { color: var(--muted); }
.profile-meta dd { margin: 0; font-variant-numeric: tabular-nums; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.07fr) minmax(0, 1fr); align-items: start; gap: 20px; }
.health-column { min-width: 0; }
.tabs { display: flex; gap: 24px; padding: 0 22px; border-bottom: 1px solid var(--line); min-height: 70px; }
.tabs button { border-radius: 0; padding: 0 1px; border-bottom: 2px solid transparent; font-size: 14px; color: var(--muted); }
.tabs button[aria-selected=true] { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.date-form { display: flex; align-items: end; gap: 10px; padding: 15px 20px; border-bottom: 1px solid var(--line); background: #fcfdfd; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.date-form label { flex: 1; min-width: 0; font-size: 12px; }
.date-form input { width: 100%; padding: 7px 8px; font-size: 13px; }
.date-form button { padding: 7px 12px; font-size: 13px; }
.health-scroll { max-height: max(350px, calc(100dvh - 460px)); overflow: auto; padding: 0 22px; }
.chart-card { padding: 20px 0 13px; border-bottom: 1px solid var(--line); }
.chart-card:last-child { border-bottom: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.chart-head h3 { font-size: 14px; font-weight: 600; margin: 0; }
.chart-head .latest { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.chart-head small { font-size: 12px; font-weight: 400; color: var(--muted); }
.chart-card > .muted { font-size: 12px; }
.chart-card .empty { padding: 23px 0; }
.chart-card svg { display: block; width: 100%; height: 145px; overflow: visible; }
.chart-card svg text { fill: #626f76; font-size: 10px; }
.chart-card svg line { stroke: #e2e9eb; stroke-width: 1; }
.chart-card svg polyline { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart-card svg circle { fill: var(--accent); }
.chart-card svg polyline.secondary-line { stroke: #3b8278; stroke-dasharray: 5 3; }
.chart-card svg circle.secondary-line { fill: #3b8278; }
.chart-card summary { font-size: 12px; color: var(--accent); cursor: pointer; padding: 6px 0; }
.chart-card details th, .chart-card details td { font-size: 12px; padding: 8px; }
.legend { font-size: 12px; color: var(--accent); }
.legend span { color: #2e7068; margin-left: 16px; }
.chat-panel { height: max(510px, calc(100dvh - 293px)); display: flex; flex-direction: column; }
.chat-heading { min-height: 70px; padding: 11px 21px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.chat-heading p { font-size: 12px; margin-top: 1px; }
.chat-heading button { font-size: 12px; padding: 5px 10px; min-height: 32px; }
.messages { flex: 1; overflow: auto; min-height: 150px; padding: 0 22px; scrollbar-gutter: stable; }
.message { padding: 18px 0; border-bottom: 1px solid #e8edef; }
.message:last-child { border-bottom: 0; }
.message-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.message-meta strong { font-weight: 600; color: var(--accent); margin-right: auto; }
.message.user .message-meta strong { color: #344750; }
.message-content { font-size: 14px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-content img { max-width: 100%; max-height: 220px; display: block; border-radius: 4px; }
.message-content button { font-size: 13px; padding: 5px 10px; color: var(--accent); background: var(--soft); border: 1px solid var(--line); }
.composer { border-top: 1px solid var(--line); padding: 14px 20px 17px; background: #fcfdfd; }
.composer label { font-size: 12px; margin-bottom: 7px; }
.composer textarea { width: 100%; resize: vertical; min-height: 68px; max-height: 170px; font-size: 14px; display: block; }
.composer-bottom { margin-top: 11px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.composer-bottom span { font-size: 12px; max-width: 68%; }
.composer-bottom button { font-size: 13px; white-space: nowrap; }
.question { padding: 19px 22px; border-bottom: 1px solid var(--line); }
.question time { font-size: 12px; color: var(--muted); }
.question h3 { font-size: 14px; font-weight: 600; margin: 8px 0; }
.question p { font-size: 14px; border-left: 2px solid #c2cdee; padding: 3px 12px; }
.question small { color: var(--muted); font-size: 12px; display: block; margin-top: 10px; }
#questions-content { max-height: max(430px, calc(100dvh - 377px)); overflow: auto; min-height: 350px; }
dialog { border: 1px solid #cdd7da; border-radius: 8px; width: min(460px, calc(100% - 28px)); padding: 25px; box-shadow: 0 20px 80px #182c3330; color: inherit; }
dialog::backdrop { background: #162b3655; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.dialog-heading h2 { font-size: 20px; }
dialog label { margin-top: 15px; }
dialog label input, dialog label select { width: 100%; }
dialog input[readonly] { background: var(--soft); }
#save-changes { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
.form-note { color: var(--muted); font-size: 12px; line-height: 1.7; margin-top: 8px; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
#form-error { margin-top: 15px; }
#notice { position: fixed; bottom: 25px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 18px; max-width: min(600px, calc(100% - 32px)); padding: 12px 16px; border: 1px solid #b4ccca; border-radius: 7px; background: #fff; box-shadow: 0 5px 25px #203a4320; font-size: 14px; z-index: 10; }
#notice[data-error=true] { border-color: #dfadb7; color: #9f3c4f; }
#notice button { padding: 2px 5px; color: inherit; }
.login-card { max-width: 420px; margin: 65px auto; padding: 35px; }
.login-card h1 { font-size: 24px; margin: 8px 0; }
.eyebrow { font-size: 12px; color: var(--accent); }
.login-card form { margin-top: 24px; display: grid; gap: 18px; }
.login-card input { width: 100%; }
.record-table td { white-space: normal; overflow-wrap: anywhere; }
.record-table tbody tr:hover { background: #f7f9fe; }
.record-table .row-actions { justify-content: start; flex-wrap: wrap; gap: 4px 12px; }
.record-table .row-actions a, .record-table .row-actions button { white-space: nowrap; }
.record-details { padding: 22px; }
.detail-fields { margin: 0; }
.detail-fields > div { display: grid; grid-template-columns: 88px minmax(0,1fr); gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.detail-fields dt { color: var(--muted); }
.detail-fields dd { margin: 0; overflow-wrap: anywhere; }
.status-tag { display: inline-block; border-radius: 4px; padding: 2px 8px; font-size: 12px; color: #415b52; background: #edf4f0; white-space: nowrap; }
.status-tag.pending { color: #805d24; background: #faf3e5; }
#management-form-error { margin-top: 15px; }
.inline-control { flex-direction: row; align-items: center; gap: 8px; white-space: nowrap; }
.approval-filters { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)) repeat(2,minmax(0,1.15fr)); gap: 14px; border: 0; margin: 0; padding: 0 20px; min-width: 0; }
.approval-filters label, .approval-filters input, .approval-filters select { width: 100%; min-width: 0; }
.filter-summary { display: flex; align-items: center; justify-content: space-between; padding: 8px 20px 12px; gap: 12px; }
.filter-summary .text-button { color: var(--accent); }
#approval-filter-error { margin: 0 20px 14px; }
.results-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); }
.results-bar select { padding-block: 5px; }
.pagination { display: flex; flex-shrink: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.password-button { color: var(--accent); padding: 0; min-height: 30px; font-size: 13px; }
#account-password { display: block; margin-top: 18px; padding: 14px; background: var(--soft); border-radius: 5px; font-family: ui-monospace, monospace; overflow-wrap: anywhere; white-space: pre-wrap; user-select: text; }
@media (max-width: 1000px) {
  .brand-note { display: none; }
  .topbar { padding-inline: 22px; gap: 18px; }
  .topbar nav { gap: 18px; }
  main { padding-inline: 22px; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .health-scroll { max-height: 400px; }
  .chat-panel { height: 600px; }
  .profile-meta { gap: 8px 18px; }
  .profile-meta > div:last-child { flex-basis: 100%; }
  .date-form { padding: 15px; gap: 8px; }
  .health-scroll, .messages { padding-inline: 18px; }
  .composer-bottom span { max-width: 58%; }
}
@media (max-width: 760px) {
  button, input, select { min-height: 44px; }
  .topbar { flex-wrap: wrap; padding: 12px 16px 0; gap: 0 12px; }
  .brand { min-height: 36px; margin-right: auto; }
  .brand strong { font-size: 22px; }
  .topbar nav { order: 1; flex-basis: 100%; overflow: auto; }
  .topbar nav a { padding: 11px 0; min-height: 44px; font-size: 12px; }
  .demo-banner { font-size: 11px; padding: 2px 6px; }
  main { padding: 23px 16px 30px; }
  h1 { font-size: 24px; }
  .page-heading { margin-bottom: 20px; gap: 10px; }
  .page-heading > .primary { font-size: 13px; padding: 8px 12px; flex-shrink: 0; }
  .count { font-size: 12px; padding-left: 9px; margin-left: 7px; }
  .page-heading .muted { font-size: 12px; }
  .toolbar { padding: 15px; flex-wrap: wrap; gap: 9px; }
  .search { max-width: none; flex-basis: 100%; }
  .search input { font-size: 16px; }
  .toolbar select { flex: 1; max-width: calc(100% - 93px); font-size: 13px; }
  .toolbar > button { font-size: 13px; padding: 8px 10px; }
  .customer-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .customer-table, .customer-table tbody { display: block; }
  .customer-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'name actions' 'phone actions' 'institution institution' 'created created'; padding: 16px; border-top: 1px solid var(--line); }
  .customer-table td { border: 0; padding: 0; white-space: normal; overflow-wrap: anywhere; }
  .name-cell { grid-area: name; font-size: 15px; }
  .phone-cell { grid-area: phone; font-size: 13px; margin-top: 2px; }
  .password-button { min-height: 44px; }
  .institution-cell { grid-area: institution; margin-top: 10px; font-size: 12px; }
  .created-cell { grid-area: created; margin-top: 3px; }
  .actions-cell { grid-area: actions; align-self: center; }
  .customer-table td[data-label]::before { content: attr(data-label); display: inline-block; color: var(--muted); width: 65px; }
  .row-actions { gap: 4px; }
  .row-actions button, .row-actions a { min-height: 44px; min-width: 44px; justify-content: center; font-size: 13px; }
  .table-footer { padding: 12px 15px; }
  .table-footer .muted { font-size: 12px; }
  .table-footer button { min-height: 44px; margin-left: 3px; padding: 6px 8px; }
  .back { padding: 0 0 14px; min-height: 36px; }
  .detail-heading { margin-bottom: 22px; }
  .detail-heading > button { font-size: 12px; margin-top: 0; padding: 8px 11px; }
  .profile-meta { display: grid; gap: 5px; font-size: 12px; margin-top: 10px; }
  .profile-meta > div { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 8px; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .tabs { min-height: 57px; padding: 0 18px; }
  .date-form { padding: 14px; gap: 7px; }
  .date-form label { font-size: 11px; }
  .date-form input { padding: 7px 5px; font-size: 12px; }
  .date-form button { padding: 7px 9px; font-size: 12px; }
  .health-scroll { max-height: 420px; padding-inline: 18px; }
  .chart-head .latest { font-size: 20px; }
  .chart-card summary { min-height: 40px; padding: 9px 0; }
  .chat-panel { height: 650px; min-height: 480px; max-height: 90dvh; }
  .chat-heading { padding: 13px 18px; }
  .chat-heading button { min-height: 44px; }
  .message-meta { gap: 6px 10px; }
  .message-content button { min-height: 44px; }
  .composer { padding-inline: 17px; }
  .composer textarea { font-size: 16px; }
  .composer-bottom span { font-size: 11px; max-width: 62%; }
  #questions-content { min-height: 330px; max-height: 430px; }
  #notice { bottom: 14px; width: calc(100% - 32px); }
  .login-card { margin: 30px auto; padding: 26px; }
  dialog input, dialog select { font-size: 16px; }
  .record-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .record-table, .record-table tbody { display: block; }
  .record-table tr { display: block; padding: 14px 16px; border-top: 1px solid var(--line); }
  .record-table td { display: grid; grid-template-columns: 72px minmax(0,1fr); gap: 8px; border: 0; padding: 4px 0; }
  .record-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; padding-top: 2px; }
  .record-table .row-actions button, .record-table .row-actions a { min-height: 44px; }
  .record-table td > .status-tag { justify-self: start; }
  .approval-filters { grid-template-columns: repeat(2,minmax(0,1fr)); padding-inline: 15px; gap: 12px; }
  .approval-filters label:nth-of-type(3) { grid-column: 1 / -1; }
  .filter-summary, .results-bar { padding-inline: 15px; }
  .filter-summary .muted { font-size: 11px; }
  .filter-summary button { white-space: nowrap; }
  #approval-filter-error { margin-inline: 15px; }
  #approval-sort-label { flex: 1; font-size: 12px; }
  #approval-sort { max-width: none; width: 100%; min-width: 0; padding-inline: 6px; }
  .results-bar { align-items: start; flex-direction: column; gap: 8px; }
  #management-panel .table-footer { flex-wrap: wrap; }
  #management-panel .pagination { margin-left: auto; }
}
@media (prefers-contrast: more) {
  :root { --line: #8b9b9f; --muted: #36464d; }
}

@media (prefers-reduced-motion: no-preference) {
  button, a, input, select, textarea { transition: background-color 120ms, border-color 120ms, color 120ms; }
}
