:root {
  color-scheme: light;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: #231932;
  background: #f6f4fa;
  font-synthesis: none;
  --canvas: #f6f4fa;
  --sidebar: #211932;
  --ink: #231932;
  --muted: #625b71;
  --line: #e9e4f0;
  --purple: #6b3fd1;
  --purple-dark: #5932b3;
  --lavender: #f0e9ff;
  --green: #167450;
  --red: #a13755;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible, canvas:focus-visible { outline: 3px solid #9567f8; outline-offset: 3px; }
button { color: inherit; }
h1, h2, h3, p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; clip: rect(0,0,0,0); overflow: hidden; white-space: nowrap; }
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 27px 18px 20px; color: #efeaf8; background: var(--sidebar); min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; margin-bottom: 57px; font-size: 26px; font-weight: 800; line-height: .95; letter-spacing: -1.3px; }
.brand-mark { flex: 0 0 37px; height: 37px; border-radius: 10px; display: grid; place-items: center; background: #c6abff; color: #281741; font-size: 22px; line-height: 1; }
.brand-dot { color: #c6abff; }
.brand small { display: block; color: #c0b4ce; font-size: 9px; line-height: 1; margin-top: 7px; letter-spacing: 1.45px; font-weight: 700; }
.side-label { display: flex; align-items: center; justify-content: space-between; padding: 0 9px 8px; color: #c0b4ce; font-size: .72rem; font-weight: 700; letter-spacing: .085em; }
.add-icon { border: 0; background: transparent; color: #e1d0ff; padding: 0; width: 28px; height: 28px; border-radius: 6px; font-size: 1.35rem; line-height: 1; }
.add-icon:hover, .new-folder:hover { background: #392d4d; }
.folders { display: grid; gap: 5px; overflow: auto; }
.folder { text-align: left; display: flex; gap: 9px; align-items: center; width: 100%; padding: 11px 10px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: #e8dff4; font-size: .88rem; }
.folder:hover { background: #392d4d; }
.folder[aria-current="page"] { color: #fff; background: #3a2b53; border-color: #4c3a69; font-weight: 650; }
.folder span:last-child { overflow-wrap: anywhere; }
.folder-icon { width: 15px; height: 11px; border: 1.5px solid #d1b9ff; border-radius: 2px; position: relative; flex: 0 0 15px; }
.folder-icon::before { content: ""; position: absolute; width: 7px; height: 4px; border: 1.5px solid #d1b9ff; border-bottom: 0; top: -4px; left: -1.5px; border-radius: 2px 2px 0 0; }
.new-folder { margin: 8px 0 20px; padding: 8px 10px; border-radius: 8px; display: flex; gap: 9px; align-items: center; border: 0; background: transparent; color: #dbc7fc; font-size: .88rem; text-align: left; }
.new-folder span { font-size: 1.2rem; line-height: 1; }
.side-footer { display: flex; gap: 10px; align-items: center; margin-top: auto; padding: 17px 8px 2px; border-top: 1px solid #443751; font-size: .8rem; }
.workspace-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: #443256; color: #dfc9ff; font-weight: 750; }
.side-footer small { display: block; margin-top: 4px; color: #c0b4ce; font-size: .72rem; }
.main { min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 32px; min-height: 60px; background: white; border-bottom: 1px solid var(--line); }
.crumb { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .85rem; min-width: 0; }
.crumb strong { color: var(--ink); font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.demo { font-size: .78rem; font-weight: 650; white-space: nowrap; color: #64429d; background: #f2eaff; border: 1px solid #eadcff; padding: 5px 9px; border-radius: 6px; display: flex; align-items: center; gap: 6px; }
.demo i { width: 6px; height: 6px; display: block; border-radius: 50%; background: #8554d6; }
.content { max-width: 1510px; margin: 0 auto; padding: 29px 32px 40px; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 18px; }
.page-head > div { min-width: 0; }
h1 { font-size: clamp(1.8rem, 3.2vw, 2.75rem); line-height: 1.08; letter-spacing: -.045em; overflow-wrap: anywhere; }
.page-head p { font-size: .95rem; line-height: 1.45; color: var(--muted); margin-top: 8px; }
.period { display: flex; flex-shrink: 0; position: relative; align-items: center; background: white; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 2px; }
.period select { font-size: .87rem; font-weight: 650; background: transparent; border: 0; appearance: none; border-radius: 8px; color: var(--ink); padding: 10px 32px 10px 34px; }
.calendar, .chevron { position: absolute; pointer-events: none; }
.calendar { left: 11px; font-size: 1rem; color: var(--purple); line-height: 1; }
.chevron { right: 13px; width: 6px; height: 6px; border-bottom: 1.5px solid #655d72; border-right: 1.5px solid #655d72; transform: translateY(-2px) rotate(45deg); }
.tabs { display: flex; gap: 20px; border-bottom: 1px solid #e3dced; margin: 15px 0 21px; overflow-x: auto; }
.tab { white-space: nowrap; border: 0; border-bottom: 2px solid transparent; padding: 12px 2px 11px; background: transparent; font-size: .9rem; font-weight: 650; color: var(--muted); }
.tab:hover, .tab[aria-current="page"] { color: var(--purple-dark); }
.tab[aria-current="page"] { border-color: var(--purple); }
.tab:focus-visible { outline-offset: -4px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 13px; margin-bottom: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 13px; min-width: 0; }
.kpi { padding: 14px 15px 13px; min-height: 110px; }
.kpi-title { color: var(--muted); font-size: .85rem; font-weight: 650; line-height: 1.25; min-height: 1.3em; }
.kpi-value { display: block; font-size: clamp(1.25rem, 2.6vw, 1.85rem); font-weight: 800; letter-spacing: -.05em; white-space: nowrap; margin: 6px 0 5px; }
.kpi-note { display: block; font-size: .75rem; color: var(--muted); line-height: 1.25; }
.kpi-highlight { background: #eee6ff; border-color: #e6d8ff; }
.kpi-highlight .kpi-value { color: #54339c; }
.kpi-highlight .kpi-title, .kpi-highlight .kpi-note { color: #5c457b; }
.overview-grid { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(0,1fr); gap: 16px; margin-bottom: 16px; }
.chart-card, .funnel-card, .empty, .source-intro { padding: 16px 17px; }
h2 { line-height: 1.2; letter-spacing: -.025em; font-size: 1.16rem; }
.subtext { font-size: .83rem; color: var(--muted); line-height: 1.4; margin-top: 5px; }
.legend { display: flex; flex-wrap: wrap; gap: 5px 16px; font-size: .77rem; color: var(--muted); margin-top: 11px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #7545dc; }
.legend span:nth-child(2) i { background: #9d80c6; }
.chart-wrap { position: relative; height: 171px; margin-top: 6px; }
canvas { display: block; width: 100%; height: 171px; }
.funnel { display: grid; gap: 11px; list-style: none; padding: 0; margin: 12px 0 0; }
.funnel-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: .83rem; }
.funnel-label strong { font-size: .88rem; }
.track { display: block; height: 5px; background: #f0eaf8; border-radius: 5px; margin-top: 5px; }
.track b { display: block; height: 100%; border-radius: 5px; background: #8b62e3; }
.funnel li:nth-child(2) b { background: #794bd8; }
.funnel li:nth-child(3) b { background: #6c3bc8; }
.funnel li:nth-child(4) b { background: #5931ae; }
.section-head { padding: 15px 17px 12px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.text-button { border: 0; border-radius: 5px; background: transparent; padding: 4px 0; color: var(--purple-dark); font-weight: 700; font-size: .82rem; text-align: left; }
.text-button:hover { text-decoration: underline; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; }
th, td { padding: 10px 12px; text-align: right; }
th:first-child, td:first-child { padding-left: 17px; text-align: left; }
th:last-child, td:last-child { padding-right: 17px; }
th { color: var(--muted); background: #f8f6fb; font-weight: 650; font-size: .78rem; }
td { border-top: 1px solid #f0ecf5; font-size: .83rem; }
tbody tr:hover { background: #fbf9ff; }
.money, .source-amount { font-weight: 700; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.table-note { padding: 11px 17px; font-size: .8rem; color: var(--muted); border-top: 1px solid #f0ecf5; line-height: 1.4; }
.empty { padding: 24px; }
.empty .secondary { margin-top: 14px; }
.view-stack { display: grid; gap: 14px; }
.patient-filter { flex: 0 0 auto; }
.patient-filter select { padding-left: 11px; }
.patient-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 2px 17px 14px; }
.patient-stats > div { min-width: 0; padding: 12px; background: #f6f1fd; border-radius: 8px; }
.patient-stats span, .patient-stats small { display: block; color: var(--muted); font-size: .8rem; line-height: 1.35; }
.patient-stats strong { display: block; color: var(--purple-dark); margin: 3px 0; font-size: 1.45rem; letter-spacing: -.04em; }
.patient-table tbody th { background: transparent; color: var(--ink); border-top: 1px solid #f0ecf5; font-size: .83rem; white-space: normal; min-width: 175px; }
.patient-table th small { display: block; color: var(--muted); font-weight: 400; line-height: 1.35; margin-top: 4px; }
.patient-table tfoot td { background: #f8f6fb; font-weight: 650; }
.integration-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.integration-card { padding: 15px 17px; }
.integration-card h3 { font-size: .98rem; }
.integration-title { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.integration-state { color: var(--purple-dark); font-weight: 650; font-size: .75rem; background: var(--lavender); border-radius: 5px; padding: 4px 6px; }
dialog { width: min(465px, calc(100% - 28px)); border: 1px solid var(--line); border-radius: 15px; color: var(--ink); padding: 21px; box-shadow: 0 18px 65px #21193238; }
dialog::backdrop { background: #21193285; }
.dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 8px; margin-bottom: 14px; }
.close { line-height: 1; font-size: 1.35rem; background: #f7f3fc; border-radius: 7px; border: 0; height: 28px; width: 28px; flex-shrink: 0; }
#folder-form label { display: block; margin-bottom: 6px; font-size: .89rem; font-weight: 650; }
#folder-name { width: 100%; padding: 10px 11px; border-radius: 7px; border: 1px solid #d9cde9; color: var(--ink); }
.form-error { font-size: .82rem; color: var(--red); margin-top: 7px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 15px; }
.primary, .secondary { border-radius: 8px; font-size: .85rem; font-weight: 650; padding: 9px 12px; border: 1px solid #e7def2; }
.primary { color: white; background: var(--purple-dark); border-color: var(--purple-dark); }
.primary:hover { background: #46258d; }
.secondary { background: white; }
.secondary:hover { background: #f6f2fc; }
.detail-list { display: grid; grid-template-columns: auto auto; gap: 9px 12px; margin: 0; font-size: .9rem; padding: 3px 0; }
.detail-list dd { margin: 0; text-align: right; font-weight: 700; }
@media (max-width: 1070px) {
  .shell { grid-template-columns: 200px minmax(0,1fr); }
  .content { padding-inline: 22px; }
  .topbar { padding-inline: 22px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 173px minmax(0,1fr); }
  .sidebar { padding-inline: 10px; }
  .brand { font-size: 22px; }
  .brand-mark { flex-basis: 30px; height: 30px; font-size: 18px; }
  .brand small { font-size: 8px; letter-spacing: .8px; }
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .overview-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .shell { grid-template-columns: minmax(0,1fr); }
  .sidebar { position: static; height: auto; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px 9px; padding: 12px 14px 10px; }
  .brand { margin: 0 0 6px; padding: 0; grid-column: 1; }
  .folder-label, .side-footer { display: none; }
  .folders { grid-column: 1 / -1; display: flex; }
  .folder { width: auto; flex: 0 0 auto; max-width: 255px; padding: 7px 8px; }
  .folder span:last-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .new-folder { grid-row: 1; grid-column: 2; margin: 0; padding: 5px; }
  .topbar { min-height: 45px; padding-inline: 13px; }
  .content { padding: 17px 12px 27px; }
  .page-head { gap: 8px; align-items: start; flex-wrap: wrap; }
  .page-head > div { flex-basis: 100%; }
  .page-head p { font-size: .85rem; }
  .tabs { gap: 13px; margin-top: 4px; margin-bottom: 13px; }
  .tab { font-size: .83rem; }
  .patient-head { flex-wrap: wrap; }
  .patient-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .patient-stats > div:last-child { grid-column: 1 / -1; }
  .kpis { gap: 7px; margin-bottom: 9px; }
  .kpi { min-height: 96px; padding: 10px; }
  .overview-grid { gap: 8px; margin-bottom: 9px; }
  .integration-list { grid-template-columns: 1fr; gap: 8px; }
}
