:root {
  --ink: #1b2a3a;
  --muted: #6d7c8c;
  --soft: #f5f8fa;
  --line: #e2e9ee;
  --navy: #173b58;
  --blue: #4c8fb7;
  --blue-soft: #e8f3f8;
  --mint: #dff0e9;
  --mint-strong: #2f8b6f;
  --amber: #f8e8c7;
  --amber-strong: #a16a1c;
  --red-soft: #fbe7e4;
  --red: #bc5b53;
  --purple-soft: #efe9f8;
  --purple: #7558a5;
  --shadow: 0 14px 32px rgba(31, 57, 75, 0.07);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { line-break: strict; }
body { margin: 0; background: #f7fafb; color: var(--ink); font-size: 14px; }
.semantic-copy > .semantic-unit { display: inline-block; max-width: 100%; vertical-align: top; margin: 0; font: inherit; color: inherit; text-wrap: pretty; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: flex; }
.sidebar { width: 248px; flex-shrink: 0; background: #fbfcfd; border-right: 1px solid var(--line); padding: 25px 16px 18px; display: flex; flex-direction: column; }
.brand-lockup { display: flex; gap: 11px; align-items: center; padding: 0 9px 24px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--navy); color: white; display: grid; place-items: center; font-weight: 700; font-size: 18px; box-shadow: 0 5px 14px rgba(23,59,88,.24); }
.brand-name { font-weight: 750; letter-spacing: 0; font-size: 17px; }
.brand-subtitle { color: var(--muted); font-size: 11px; margin-top: 3px; letter-spacing: 0; }
.local-chip { margin: 0 8px 25px; border: 1px solid #dce7e8; background: #f3faf7; color: #3c6f63; padding: 8px 10px; border-radius: 7px; font-size: 12px; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #52ad84; margin-right: 6px; vertical-align: 1px; }
.nav-label { color: #96a3af; text-transform: uppercase; font-size: 10px; letter-spacing: 0; padding: 0 10px 9px; }
.role-nav { display: grid; gap: 6px; }
.role-button { background: transparent; border: 1px solid transparent; color: var(--muted); min-height: 58px; display: grid; grid-template-columns: 30px 1fr auto; grid-template-rows: 21px 17px; text-align: left; align-items: center; padding: 8px 10px; border-radius: 8px; }
.role-button:hover { background: var(--soft); color: var(--navy); }
.role-button.active { background: #eaf3f6; border-color: #d8e8eb; color: var(--navy); }
.role-icon { grid-row: 1 / span 2; font-size: 19px; color: var(--blue); display: grid; place-items: center; }
.role-button span:not(.role-icon) { font-weight: 650; }
.role-button small { color: #93a1ad; font-size: 11px; }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--line); padding: 17px 8px 0; }
.mini-profile { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; }
.avatar, .top-avatar { display: grid; place-items: center; background: #dbeaf0; color: var(--navy); font-weight: 700; border-radius: 50%; }
.avatar { width: 29px; height: 29px; font-size: 12px; }
.mini-profile strong, .mini-profile span { display: block; }
.mini-profile strong { font-size: 12px; }
.mini-profile span { color: var(--muted); font-size: 10px; margin-top: 2px; }
.text-button { color: var(--muted); border: none; background: transparent; padding: 0; font-size: 12px; }
.text-button:hover { color: var(--navy); }
.main-area { min-width: 0; flex: 1; }
.topbar { height: 72px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 36px; }
.breadcrumb { display: flex; gap: 12px; align-items: center; color: var(--muted); }
.breadcrumb b { color: #ccd5db; font-weight: 400; }
.breadcrumb strong { color: var(--ink); font-size: 15px; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.db-pill { background: #f4faf7; color: #3c6f63; border: 1px solid #d9e9df; border-radius: 999px; padding: 7px 10px; font-size: 11px; }
.icon-button { background: transparent; border: none; color: #708391; position: relative; font-size: 21px; line-height: 1; }
.icon-button i { position: absolute; width: 5px; height: 5px; border-radius: 50%; right: 0; top: 0; background: #d78163; }
.top-avatar { width: 30px; height: 30px; font-size: 12px; }
.content { max-width: 1400px; margin: 0 auto; padding: 34px 36px 60px; }
.page-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 20px; margin-bottom: 28px; }
.heading-copy { min-width: 0; }
.heading-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.eyebrow { color: var(--blue); font-size: 11px; letter-spacing: 0; text-transform: uppercase; margin-bottom: 9px; font-weight: 700; }
h1 { font-size: 26px; margin: 0 0 9px; letter-spacing: 0; line-height: 1.4; }
.page-heading p { color: var(--muted); margin: 0; line-height: 1.8; text-wrap: pretty; }
.primary-button, .secondary-button, .quiet-button { border-radius: 6px; padding: 10px 15px; border: 1px solid transparent; font-weight: 650; white-space: nowrap; }
.primary-button { background: var(--navy); color: white; box-shadow: 0 5px 12px rgba(23,59,88,.16); }
.primary-button:hover { background: #214f72; }
.secondary-button { background: white; color: var(--navy); border-color: #c9dbe3; }
.quiet-button { padding: 7px 10px; background: #f3f7f9; color: var(--navy); font-size: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 23px; }
.stat-card, .panel { background: white; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.stat-card { padding: 18px 18px 15px; min-height: 112px; }
.stat-label { color: var(--muted); font-size: 12px; display: flex; align-items: center; justify-content: space-between; }
.stat-value { font-size: 27px; font-weight: 750; color: var(--navy); letter-spacing: 0; margin: 13px 0 3px; }
.stat-note { color: #8d9ba6; font-size: 11px; line-height: 1.6; }
.stat-note.positive { color: var(--mint-strong); }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, .95fr); gap: 18px; align-items: start; }
.workspace-grid > * { min-width: 0; }
.workspace-grid > div > .panel + .panel { margin-top: 18px; }
.panel { overflow: hidden; }
.panel-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 19px; border-bottom: 1px solid var(--line); }
.panel-header > div { min-width: 0; flex: 1 1 190px; }
.panel-header > button { flex-shrink: 0; }
.panel-title { font-size: 14px; font-weight: 700; line-height: 1.6; }
.panel-subtitle { color: var(--muted); font-size: 11px; margin-top: 4px; line-height: 1.7; }
.panel-body { padding: 18px 19px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 18px; border-bottom: 1px solid #edf1f3; font-size: 12px; white-space: nowrap; }
th { color: #82919c; font-size: 10px; letter-spacing: 0; text-transform: uppercase; font-weight: 700; background: #fbfcfd; }
td { color: #33495a; }
tr:last-child td { border-bottom: none; }
.name-cell strong, .name-cell span { display: block; }
.name-cell strong { font-size: 12px; color: var(--ink); }
.name-cell span { color: #93a0aa; font-size: 10px; margin-top: 3px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 10px; font-weight: 700; }
.badge.blue { color: #397693; background: var(--blue-soft); }
.badge.mint { color: #347962; background: var(--mint); }
.badge.amber { color: var(--amber-strong); background: var(--amber); }
.badge.red { color: var(--red); background: var(--red-soft); }
.badge.purple { color: var(--purple); background: var(--purple-soft); }
.empty-state { padding: 33px 20px; text-align: center; color: var(--muted); }
.flow-list { display: grid; gap: 17px; }
.flow-item { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; }
.flow-icon { width: 26px; height: 26px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; border-radius: 7px; font-size: 13px; }
.flow-item strong { display: block; font-size: 12px; margin-bottom: 4px; }
.flow-item span { color: var(--muted); font-size: 11px; line-height: 1.55; }
.flow-time { color: #9daab4; font-size: 10px; }
.signal-list { display: grid; gap: 8px; }
.signal-row { display: grid; grid-template-columns: minmax(0, 1fr) 45px 72px; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid #edf1f3; }
.signal-row:last-child { border-bottom: none; }
.signal-row strong { font-size: 12px; }
.signal-row small { display: block; color: var(--muted); margin-top: 3px; font-size: 10px; }
.signal-score { font-size: 16px; color: var(--navy); font-weight: 750; text-align: right; }
.causal-chain { display: flex; align-items: stretch; gap: 8px; margin: 16px 0 20px; }
.chain-node { flex: 1; min-width: 0; padding: 12px; border: 1px solid #dce6ea; border-radius: 7px; background: #fbfcfd; }
.chain-node b { display: block; color: var(--blue); font-size: 10px; margin-bottom: 6px; }
.chain-node span { font-size: 12px; font-weight: 650; line-height: 1.45; }
.chain-arrow { align-self: center; color: #a7b8c1; }
.question-list { margin: 0; padding-left: 20px; color: #526673; line-height: 1.8; font-size: 12px; }
.guardrail { padding: 14px; border-radius: 7px; background: #f8f4ea; color: #765c35; font-size: 12px; line-height: 1.8; margin-top: 15px; }
.guardrail > strong { display: block; color: #5e4728; margin-bottom: 5px; white-space: nowrap; }
.hero-user { display: grid; grid-template-columns: 1.28fr .72fr; gap: 18px; margin-bottom: 20px; }
.user-hero { background: var(--navy); color: white; border-radius: 9px; padding: 28px; position: relative; overflow: hidden; min-height: 212px; }
.user-hero::after { content: ""; position: absolute; width: 200px; height: 200px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; right: -60px; top: -75px; }
.user-hero h2 { font-size: 24px; line-height: 1.5; margin: 0 0 13px; position: relative; z-index: 1; }
.user-hero p { color: #c8dae4; max-width: 450px; line-height: 1.7; margin: 0 0 20px; position: relative; z-index: 1; }
.user-hero .primary-button { background: #d9eee9; color: #215b54; box-shadow: none; position: relative; z-index: 1; }
.next-appointment { padding: 22px; display: flex; flex-direction: column; justify-content: space-between; }
.next-appointment .date-large { font-size: 28px; color: var(--navy); font-weight: 750; margin: 14px 0 3px; }
.next-appointment .date-sub { color: var(--muted); font-size: 11px; }
.next-appointment .appointment-meta { color: #536a78; font-size: 12px; line-height: 1.7; margin-top: 18px; }
.report-list { display: grid; gap: 10px; }
.report-item { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 15px; padding: 13px 0; border-bottom: 1px solid #edf1f3; }
.report-item > div:first-child { flex: 1 1 260px; min-width: 0; }
.report-item:last-child { border-bottom: none; }
.report-item strong { display: block; font-size: 12px; }
.report-item > div:first-child > span { color: var(--muted); font-size: 12px; display: block; line-height: 1.8; margin-top: 5px; }
.report-actions { display: flex; gap: 7px; align-items: center; }
.store-list { display: grid; gap: 10px; }
.store-row { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center; padding: 11px 0; border-bottom: 1px solid #edf1f3; }
.store-row:last-child { border-bottom: none; }
.store-name strong { display: block; font-size: 12px; }
.store-name span { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; }
.store-number { font-weight: 700; color: var(--navy); font-size: 13px; }
.store-caption { color: var(--muted); font-size: 10px; }
.audit-list { display: grid; gap: 14px; }
.audit-item { display: grid; grid-template-columns: 27px 1fr auto; gap: 9px; align-items: start; }
.audit-dot { width: 25px; height: 25px; border-radius: 7px; background: #f1f5f7; color: var(--blue); display: grid; place-items: center; font-size: 12px; }
.audit-item strong { font-size: 11px; display: block; }
.audit-item span { color: var(--muted); font-size: 10px; display: block; margin-top: 3px; }
.audit-item time { color: #9aa8b1; font-size: 10px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(21, 40, 55, .35); display: grid; place-items: center; z-index: 10; padding: 18px; }
.modal { width: min(450px, 100%); max-height: calc(100dvh - 36px); overflow-y: auto; background: white; border-radius: 8px; box-shadow: 0 25px 60px rgba(14, 33, 48, .2); }
.modal-header, .modal-footer { padding: 17px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-footer { border-top: 1px solid var(--line); border-bottom: none; justify-content: flex-end; gap: 8px; }
.modal h3 { margin: 0; font-size: 16px; }
.modal-close { background: transparent; border: none; font-size: 20px; color: var(--muted); }
.form-body { padding: 19px 20px; display: grid; gap: 14px; }
.form-field label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.form-field input, .form-field select { width: 100%; border: 1px solid #cfdae0; border-radius: 5px; padding: 10px 11px; color: var(--ink); background: white; outline: none; }
.form-field input:focus, .form-field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(76,143,183,.12); }
.toast { position: fixed; right: 25px; bottom: 25px; transform: translateY(20px); opacity: 0; pointer-events: none; transition: .22s ease; background: #203e53; color: white; padding: 12px 15px; border-radius: 6px; box-shadow: 0 9px 25px rgba(21, 49, 66, .22); font-size: 12px; z-index: 20; }
.toast.show { transform: translateY(0); opacity: 1; }
.muted { color: var(--muted); }
.section-gap { margin-top: 18px; }
.inline-actions { display: flex; gap: 8px; align-items: center; }
.check-list { display: grid; gap: 9px; }
.check-item { display: flex; align-items: flex-start; gap: 9px; color: #526673; font-size: 12px; line-height: 1.8; }
.check-item::before { content: "✓"; flex-shrink: 0; width: 18px; height: 18px; margin-top: 2px; border-radius: 50%; background: var(--mint); color: var(--mint-strong); display: grid; place-items: center; font-size: 11px; font-weight: 700; }

@media (max-width: 1240px) {
  .page-heading { grid-template-columns: minmax(0, 1fr); gap: 16px; }
}

@media (max-width: 1050px) {
  .sidebar { width: 212px; }
  .content, .topbar { padding-left: 24px; padding-right: 24px; }
  .workspace-grid, .hero-user { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--line); padding: 13px 14px; }
  .brand-lockup { padding: 0 6px 12px; }
  .local-chip, .nav-label, .sidebar-footer { display: none; }
  .role-nav { grid-template-columns: repeat(4, 1fr); gap: 3px; }
  .role-button { min-height: 48px; display: block; text-align: center; padding: 6px 2px; }
  .role-icon { display: inline; margin-right: 3px; font-size: 15px; }
  .role-button small { display: none; }
  .topbar { height: 58px; padding: 0 16px; }
  .db-pill { display: none; }
  .content { padding: 23px 16px 40px; }
  .page-heading { gap: 16px; margin-bottom: 24px; }
  .heading-actions { width: 100%; }
  .heading-actions > button { min-height: 42px; padding: 10px 12px; font-size: 13px; flex: 1; }
  .heading-actions > button:only-child { flex: 0 1 auto; }
  .panel-header, .panel-body { padding: 16px; }
  .user-hero { padding: 22px; }
  .user-hero h2 { font-size: 20px; }
  .user-hero p { font-size: 13px; line-height: 1.85; }
  .toast { left: 16px; right: 16px; bottom: 16px; line-height: 1.7; }
  .flow-item { grid-template-columns: 26px minmax(0, 1fr); }
  .flow-item > button { grid-column: 2; justify-self: start; }
  .store-row { grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; }
  .store-name strong { line-height: 1.6; }
  .signal-row { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; }
  .signal-row > div:first-child { grid-column: 1; grid-row: 1 / span 2; }
  .signal-row > .badge { grid-column: 2; justify-self: end; }
  .signal-row strong { line-height: 1.7; }
  .table-wrap { overflow-x: visible; }
  table, tbody { display: block; width: 100%; }
  thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
  tbody tr:first-child { padding-top: 0; }
  tbody tr:last-child { padding-bottom: 0; }
  td { min-width: 0; border: 0; padding: 0; white-space: normal; line-height: 1.6; }
  td:first-child { grid-column: 1 / -1; }
  td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; }
  td:last-child { align-self: end; justify-self: end; }
  .name-cell span { line-height: 1.7; }
  .report-item { flex-wrap: wrap; }
  .report-actions { margin-left: auto; }
  .audit-item { grid-template-columns: 27px minmax(0, 1fr); }
  .audit-item time { grid-column: 2; }
  h1 { font-size: 22px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .stat-card { min-height: 100px; padding: 14px; }
  .stat-value { font-size: 23px; }
  .causal-chain { display: grid; grid-template-columns: 1fr; }
  .chain-arrow { transform: rotate(90deg); justify-self: center; }
  .check-item > .semantic-copy { min-width: 0; }
}
