/* ==========================================================
   Screens (Analytics, Billing, Pharmacy, Calendar) + shared UI
   ========================================================== */
.screen { display: none; flex-direction: column; gap: 12px; }
.screen.active { display: flex; }
.ink { color: var(--ink); font-weight: 600; }
.row-split { display: grid; grid-template-columns: 2.2fr 1fr; gap: 12px; }
.row-half { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.row-split > *, .row-half > * { min-width: 0; }

/* View modes */
.layout { transition: grid-template-columns .5s var(--ease), gap .5s var(--ease); }
.sidebar { transition: opacity .35s; }
.app.focus .layout { grid-template-columns: 0 1fr; gap: 0; }
.app.focus .sidebar { opacity: 0; pointer-events: none; overflow: hidden; }
.app.compact .card { padding: 12px 14px; }
.app.compact .screen, .app.compact .main { gap: 8px; }
.app.compact .row1, .app.compact .row2, .app.compact .row-split, .app.compact .row-half, .app.compact .kpi-row, .app.compact .mini-grid, .app.compact .row1-right { gap: 8px; }
.app.compact .big { font-size: 22px; }
.calm *, .calm *::before, .calm *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }

/* KPI cards */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi { display: flex; flex-direction: column; gap: 10px; cursor: pointer; }
.kpi:hover { box-shadow: var(--shadow-lg); }
.kpi-head { display: flex; align-items: center; justify-content: space-between; }
.kpi-ic { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #eef3ff; color: var(--blue); }
.kpi-ic svg { width: 14px; height: 14px; }
.kpi .label { font-size: 11px; color: var(--muted); }
.kpi .val { font-size: 24px; letter-spacing: -.02em; }
.kpi-foot { display: flex; align-items: flex-end; justify-content: space-between; }
.kpi .spark svg { width: 70px; height: 26px; }
.kpi.dark-kpi { background: var(--black); color: #fff; }
.kpi.dark-kpi .kpi-ic { background: #2c2d34; color: #fff; }
.kpi.dark-kpi .spark svg { stroke: var(--sky); }
.trend-chip { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.trend-chip.up { background: #dcfce7; color: #15803d; }
.trend-chip.down { background: #fee2e2; color: #b91c1c; }
.dark-kpi .trend-chip.up { background: rgba(34,197,94,.18); color: #4ade80; }
.dark-kpi .trend-chip.down { background: rgba(239,68,68,.18); color: #f87171; }

/* Line chart */
.line-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.line-chart { width: 100%; height: auto; display: block; overflow: visible; stroke: none; }
.line-chart .grid { stroke: #eef0f4; stroke-width: 1; }
.line-chart text { fill: var(--muted); font-size: 9.5px; stroke: none; font-family: inherit; }
.line-chart .l-adm { stroke: var(--blue); stroke-width: 2.4; fill: none; }
.line-chart .l-dis { stroke: var(--black); stroke-width: 1.6; fill: none; stroke-dasharray: 5 5; }
.line-chart .area { fill: url(#areaGrad); }
.line-chart .clip-rect { transform-box: fill-box; transform-origin: left; animation: wipe 1.4s var(--ease) both; }
@keyframes wipe { from { transform: scaleX(0); } }
.line-chart .guide { stroke: #c9d3e6; stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; transition: opacity .2s; }
.line-chart .pt { opacity: 0; transition: opacity .2s; stroke: #fff; stroke-width: 2; }
.line-chart.hovering .guide, .line-chart.hovering .pt { opacity: 1; }
.pt.a { fill: var(--blue); } .pt.d { fill: var(--black); }

/* Donut */
.donut-wrap { position: relative; width: 170px; margin: 6px auto 14px; }
.donut { width: 100%; height: auto; display: block; transform: rotate(-90deg); stroke: none; }
.donut circle { fill: none; stroke-width: 13; transition: stroke-dasharray 1.1s var(--ease), stroke-width .25s; cursor: pointer; }
.donut circle.track { stroke: #f1f3f6; cursor: default; }
.donut circle.seg:hover { stroke-width: 16; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center strong { font-weight: 500; font-size: 22px; letter-spacing: -.02em; }
.donut-center small { font-size: 9.5px; color: var(--muted); }
.donut-legend { display: flex; flex-direction: column; gap: 10px; }
.donut-legend li { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 8px; font-size: 11.5px; }
.donut-legend i { width: 8px; height: 8px; border-radius: 50%; }
.donut-legend b { font-weight: 600; }

/* Horizontal bars */
.hbars { display: flex; flex-direction: column; gap: 12px; }
.hrow { display: grid; grid-template-columns: 46px 1fr 56px; align-items: center; gap: 10px; font-size: 11px; }
.hrow .lab { color: var(--muted); }
.hrow .val { text-align: right; font-weight: 500; }
.htrack { height: 22px; border-radius: 8px; background: #f3f4f7; overflow: hidden; }
.hfill { height: 100%; width: 0; border-radius: 8px; position: relative; overflow: hidden; transition: width 1.1s var(--ease); }
.hfill::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(135deg, rgba(255,255,255,.16) 0 3px, transparent 3px 9px); background-size: 25.5px 25.5px; animation: stripes 1.8s linear infinite; }
.hrow:hover .hfill { filter: brightness(1.12); }

/* Diagnoses */
.diag { display: flex; flex-direction: column; gap: 12px; }
.diag li { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; }
.diag .rank { width: 26px; height: 26px; border-radius: 50%; background: #f1f3f6; display: grid; place-items: center; font-size: 10px; font-weight: 600; }
.diag li:first-child .rank { background: var(--blue); color: #fff; }
.diag .nm { font-size: 11.5px; margin-bottom: 5px; }
.diag .meter { width: 100%; }
.diag .cnt { font-size: 11.5px; font-weight: 500; text-align: right; }
.diag .cnt small { display: block; font-size: 9.5px; font-weight: 600; }
.diag .cnt small.up { color: #15803d; } .diag .cnt small.down { color: #b91c1c; }
.meter { width: 90px; height: 6px; background: #eef0f4; border-radius: 999px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; border-radius: 999px; transition: width 1s var(--ease); }

/* Vertical bars */
.rev-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.vbars { height: 190px; display: flex; align-items: stretch; gap: 8px; }
.vbars.tall { height: 270px; }
.vcol { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; cursor: pointer; }
.vtrack { flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.vtrack .bar { max-width: 46px; border-radius: 10px; }
.vlab { font-size: 9.5px; color: var(--muted); white-space: nowrap; }
.vcol:hover .bar { filter: brightness(1.12); transform: scaleX(1.06); }
.vcol.cur .vlab { color: var(--blue); font-weight: 600; }
.bar.fc { background: #f1f3f6; border: 1.5px dashed #cfd5df; }
.bar.fc::after { display: none; }
.vcol .chip { background: var(--black); color: #fff; border-color: var(--black); margin-bottom: 5px; }

/* Claims */
.claim-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.claim-list li { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; font-size: 11.5px; }
.claim-list i { width: 8px; height: 8px; border-radius: 50%; }

/* Tables */
.search { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); transition: border-color .25s, box-shadow .25s; }
.search:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30,107,255,.12); }
.search svg { width: 13px; height: 13px; }
.search input { border: 0; outline: 0; background: transparent; font: inherit; font-size: 11px; color: var(--ink); width: 150px; transition: width .35s var(--ease); }
.search input:focus { width: 190px; }
.tbl-wrap { overflow-x: auto; margin: 0 -6px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.tbl th { text-align: left; font-weight: 500; font-size: 10px; color: var(--muted); padding: 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl .r { text-align: right; }
.tbl tbody tr { transition: background .2s; animation: rowIn .45s var(--ease) both; animation-delay: var(--rd, 0ms); }
.tbl tbody tr:hover { background: #f6f8fb; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr:last-child td { border-bottom: 0; }
@keyframes rowIn { from { opacity: 0; transform: translateY(6px); } }
.tbl .sub { display: block; font-size: 9.5px; color: var(--muted); }
.tbl .empty td { text-align: center; color: var(--muted); padding: 24px; }
.who { display: flex; align-items: center; gap: 8px; }
.ini { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 9.5px; font-weight: 600; color: #fff; flex-shrink: 0; }
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.st::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.st.paid, .st.ok, .st.done { background: #dcfce7; color: #15803d; }
.st.pending, .st.low { background: #fef3c7; color: #b45309; }
.st.overdue, .st.critical, .st.cancelled { background: #fee2e2; color: #b91c1c; }
.st.ordered, .st.scheduled { background: #dbeafe; color: #1d4ed8; }
.mini-btn { font-size: 10px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--ink); color: #fff; position: relative; overflow: hidden; transition: transform .2s var(--ease), background .2s; }
.mini-btn:hover { background: var(--blue); transform: translateY(-1px); }
.mini-btn.ghost-btn { background: #f1f3f6; color: var(--ink); }
.mini-btn.ghost-btn:hover { background: #e4e7ec; }
.mini-btn.danger { background: #fee2e2; color: #b91c1c; }
.mini-btn.danger:hover { background: var(--red); color: #fff; }

/* Dues + payments */
.dues .big { font-size: 26px; margin: 4px 0 6px; }
.small-label.light { color: #9ea3ae; }
.dues .dark-content { gap: 18px; }
.dues .join { align-self: flex-start; }
.join.done { background: var(--green); box-shadow: 0 8px 18px -8px rgba(34,197,94,.9); }
.join[disabled] { cursor: default; }
.spin { width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.stackbar { display: flex; gap: 3px; height: 12px; border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.stackbar i { height: 100%; width: 0; transition: width 1s var(--ease); }
.stackbar i:first-child { border-radius: 999px 0 0 999px; }
.stackbar i:last-child { border-radius: 0 999px 999px 0; }
.pay-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pay-list li { display: flex; flex-direction: column; gap: 2px; font-size: 10.5px; color: var(--muted); padding-left: 10px; border-left: 3px solid; }
.pay-list b { color: var(--ink); font-size: 14px; font-weight: 500; }

/* Pharmacy */
#pMatrix { grid-template-columns: 80px repeat(7, 1fr); }
.expiry { justify-content: flex-start; gap: 14px; }
.expiry h4 { font-size: 17px; }
.exp-sub { font-size: 11px; color: #9ea3ae; margin-top: 2px; }
.exp-sub b { color: #fff; }
.exp-list { display: flex; flex-direction: column; gap: 8px; }
.exp-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: 12px; background: #26272e; font-size: 11px; transition: background .2s, transform .25s var(--ease); }
.exp-list li:hover { background: #2f3038; transform: translateX(3px); }
.exp-list small { display: block; color: #8b909b; font-size: 9.5px; }
.exp-list .none { justify-content: center; color: #8b909b; }
.days { font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: rgba(239,68,68,.2); color: #f87171; white-space: nowrap; }
.days.mid { background: rgba(245,158,11,.2); color: #fbbf24; }
.days.far { background: rgba(169,201,255,.18); color: var(--sky); }
.expiry .join { align-self: flex-start; margin-top: auto; }

/* Calendar */
.cal-layout { display: grid; grid-template-columns: 290px 1fr; gap: 12px; }
.cal-layout > * { min-width: 0; }
.mini-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.mini-cal .wd { font-size: 9.5px; color: var(--muted); padding-bottom: 4px; }
.mini-cal button { position: relative; aspect-ratio: 1; border-radius: 50%; font-size: 11px; display: grid; place-items: center; transition: background .2s, color .2s, transform .2s var(--ease); }
.mini-cal button:hover { background: #eef1f6; transform: scale(1.08); }
.mini-cal button.out { color: #c3c7cf; }
.mini-cal button.inweek { background: #eef3ff; border-radius: 10px; }
.mini-cal button.today { background: var(--blue); color: #fff; box-shadow: 0 6px 14px -6px rgba(30,107,255,.9); }
.mini-cal button.sel:not(.today) { background: var(--ink); color: #fff; }
.mini-cal button.has::after { content: ""; position: absolute; bottom: 3px; width: 4px; height: 4px; border-radius: 50%; background: var(--navy); }
.mini-cal button.today.has::after, .mini-cal button.sel.has::after { background: #fff; }
.mini-cal.slide { animation: calSlide .4s var(--ease); }
@keyframes calSlide { from { opacity: 0; transform: translateX(var(--dir, 12px)); } }

.docs { display: flex; flex-direction: column; gap: 4px; }
.docs li { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 12px; cursor: pointer; transition: background .2s, box-shadow .2s; }
.docs li:hover, .docs li.on { background: #f3f5f9; }
.docs li.on { box-shadow: inset 0 0 0 1.5px var(--blue); }
.docs .info { flex: 1; min-width: 0; line-height: 1.3; }
.docs .info b { display: block; font-weight: 500; font-size: 11.5px; }
.docs .info small { color: var(--muted); font-size: 9.5px; }
.status { font-size: 9px; font-weight: 600; padding: 3px 7px; border-radius: 999px; white-space: nowrap; }
.status.available { background: #dcfce7; color: #15803d; }
.status.surgery { background: #dbeafe; color: #1d4ed8; }
.status.break { background: #fef3c7; color: #b45309; }
.status.off { background: #f1f3f6; color: var(--muted); }

.schedule { display: flex; flex-direction: column; }
.sched-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.sched-stats span { background: var(--app); border-radius: 12px; padding: 8px 12px; font-size: 10px; color: var(--muted); }
.sched-stats b { display: block; font-size: 16px; font-weight: 500; color: var(--ink); }
.sched-wrap { overflow-x: auto; padding-bottom: 10px; }
.sched { --hour: 46px; display: grid; grid-template-columns: 44px repeat(6, minmax(92px, 1fr)); min-width: 620px; }
.sched .dh { text-align: center; padding-bottom: 8px; font-size: 10px; color: var(--muted); }
.sched .dh b { display: grid; place-items: center; width: 28px; height: 28px; margin: 2px auto 0; border-radius: 50%; font-size: 12.5px; font-weight: 500; color: var(--ink); }
.sched .dh.today b { background: var(--blue); color: #fff; }
.sched .dh.sel:not(.today) b { background: var(--ink); color: #fff; }
.sched .times { position: relative; }
.sched .times span { position: absolute; right: 8px; font-size: 9px; color: var(--muted); transform: translateY(-50%); }
.sched .day { position: relative; height: calc(var(--hour) * 9); border-left: 1px solid var(--line);
  background: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hour)); }
.sched .day.today { background-color: #f7faff; }
.appt {
  position: absolute; left: 4px; right: 4px; border-radius: 10px; padding: 6px 8px; overflow: hidden;
  font-size: 9.5px; line-height: 1.3; cursor: pointer; text-align: left;
  animation: pop .5s var(--ease) both; animation-delay: var(--ad, 0ms);
  transition: transform .25s var(--ease), box-shadow .25s, opacity .3s, filter .3s;
}
.appt:hover { transform: translateY(-2px); box-shadow: 0 10px 18px -10px rgba(16,24,40,.5); z-index: 2; }
.appt b { display: block; font-weight: 600; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt small { display: block; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt.consultation { background: var(--blue); color: #fff; }
.appt.surgery { background: var(--black); color: #fff; }
.appt.surgery::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(135deg, rgba(255,255,255,.07) 0 3px, transparent 3px 9px); pointer-events: none; }
.appt.checkup { background: var(--navy); color: #fff; }
.appt.followup { background: var(--sky); color: #102a6b; }
.appt.done { opacity: .5; }
.appt.done b::before { content: "✓ "; }
.appt.dim { opacity: .15; filter: grayscale(1); pointer-events: none; }
.now-line { position: absolute; left: -1px; right: 0; height: 2px; background: var(--red); z-index: 3; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: livePulse 1.6s infinite; }
.sched-legend { margin-top: 12px; }

/* Notifications */
.notif { cursor: pointer; position: relative; }
.notif.unread::after { content: ""; position: absolute; right: 10px; top: 14px; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }
.dd-foot { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px 4px; border-top: 1px solid var(--line); margin-top: 4px; font-size: 10.5px; }
.dd-foot button { color: var(--blue); font-weight: 600; }
.dd-item .sw { margin-left: auto; width: 26px; height: 15px; border-radius: 999px; background: #dfe2e8; position: relative; transition: background .25s; flex-shrink: 0; }
.dd-item .sw::before { content: ""; position: absolute; left: 2px; top: 2px; width: 11px; height: 11px; border-radius: 50%; background: #fff; transition: transform .3s var(--ease); }
.dd-item.on .sw { background: var(--blue); }
.dd-item.on .sw::before { transform: translateX(11px); }
.dd-sep { height: 1px; background: var(--line); margin: 4px 6px; }

/* Modal content */
.modal-card { max-height: 88vh; overflow-y: auto; }
.modal-card.wide { width: min(640px, 100%); }
.m-sub { color: var(--muted) !important; margin-bottom: 14px; }
.m-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.m-actions .join { flex: 1; justify-content: center; padding: 10px; }
.btn-sec { flex: 1; padding: 10px; border-radius: 999px; background: #f1f3f6; font-size: 11.5px; font-weight: 500; position: relative; overflow: hidden; transition: background .2s; }
.btn-sec:hover { background: #e4e7ec; }
.btn-sec.danger { background: #fee2e2; color: #b91c1c; }
.btn-sec.danger:hover { background: var(--red); color: #fff; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.kv div { background: var(--app); border-radius: 12px; padding: 10px 12px; }
.kv small { display: block; color: var(--muted); font-size: 10px; margin-bottom: 2px; }
.kv b { font-weight: 500; font-size: 12.5px; }
.m-list { display: flex; flex-direction: column; }
.m-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 12px; animation: rowIn .35s var(--ease) both; }
.m-list li:last-child { border-bottom: 0; }
.m-list li.gone { animation: shrinkOut .35s var(--ease) forwards; }
.m-list small { display: block; color: var(--muted); font-size: 10px; }
.m-list .btns { display: flex; gap: 6px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 10.5px; color: var(--muted); }
.field input, .field select { height: 38px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font: inherit; font-size: 12px; color: var(--ink); background: #fff; outline: none; transition: border-color .2s, box-shadow .2s; }
.field input:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30,107,255,.12); }
.field.err input, .field.err select { border-color: var(--red); animation: shake .35s; }
.field .msg { font-size: 10px; color: var(--red); min-height: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.big-check { width: 56px; height: 56px; border-radius: 50%; background: #dcfce7; color: #16a34a; display: grid; place-items: center; margin: 4px auto 12px; animation: pop .5s var(--ease); }
.big-check svg { width: 26px; height: 26px; stroke-width: 2.6; }
.center { text-align: center; }

/* Signed-out overlay */
.signout { position: fixed; inset: 0; z-index: 95; background: var(--page); display: grid; place-items: center; padding: 16px; opacity: 0; pointer-events: none; transition: opacity .4s; }
.signout.open { opacity: 1; pointer-events: auto; }
.signout .modal-card { transform: none; text-align: center; }

@media (max-width: 1180px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1024px) {
  .row-split, .row-half, .cal-layout { grid-template-columns: 1fr; }
  .app.focus .layout { grid-template-columns: 1fr; }
  .app.focus .sidebar { display: none; }
}
@media (max-width: 520px) {
  .kpi-row { grid-template-columns: 1fr; }
  .pay-list, .form-grid { grid-template-columns: 1fr; }
  .kv b { word-break: break-word; }
  .search input, .search input:focus { width: 110px; }
  .card-head { flex-wrap: wrap; }
}

@media print {
  body { padding: 0; background: #fff; }
  .topbar, .sidebar, .head-actions, .toasts, .modal, .dropdown, .tooltip, .signout { display: none !important; }
  .layout { display: block; }
  .app { box-shadow: none; max-width: none; }
  .stagger, .reveal { opacity: 1 !important; animation: none !important; transform: none !important; }
  .card { break-inside: avoid; box-shadow: 0 0 0 1px #e5e7eb; }
}

/* ===== Portfolio case-study notice ===== */
.case-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 28px; background: var(--black); color: #d5d8df; font-size: 12px;
  box-shadow: 0 12px 30px -16px rgba(15,23,42,.6); animation: rise .7s var(--ease) both;
}
.case-bar p { flex: 1; line-height: 1.45; }
.case-bar b { color: #fff; font-weight: 600; }
.cb-ic { width: 30px; height: 30px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.cb-ic svg { width: 14px; height: 14px; }
.cb-link { background: #fff; color: var(--ink); font-size: 11.5px; font-weight: 600; padding: 7px 14px; border-radius: 999px; white-space: nowrap; transition: background .2s, color .2s, transform .2s var(--ease); }
.cb-link:hover { background: var(--blue); color: #fff; transform: translateY(-1px); }
.cb-x { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #9ea3ae; transition: background .2s, color .2s; }
.cb-x:hover { background: #2c2d34; color: #fff; }
.cb-x svg { width: 13px; height: 13px; }
.case-bar.gone { animation: shrinkOut .35s var(--ease) forwards; }
.demo-chip { margin-left: 4px; font-size: 9.5px; font-weight: 600; color: #b45309; background: #fef3c7; padding: 2px 8px; border-radius: 999px; }
.credit { padding: 0 28px 18px; text-align: center; font-size: 11px; color: #7d828d; }
.credit b { color: var(--ink-2); font-weight: 600; }

/* Case-study modal */
.cs-eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 600; letter-spacing: .06em; color: var(--blue); background: #eef3ff; padding: 4px 10px; border-radius: 999px; margin-bottom: 12px; }
.cs-eyebrow svg { width: 11px; height: 11px; }
.cs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0 4px; }
.cs-box { background: var(--app); border-radius: 14px; padding: 12px 14px; }
.cs-box h5 { font-size: 11px; font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.cs-box h5 i { width: 7px; height: 7px; border-radius: 50%; }
.cs-box ul { list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--ink-2); }
.cs-box li::before { content: "– "; color: var(--muted); }
.cs-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.cs-meta span { font-size: 10.5px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); }

@media (max-width: 720px) {
  .case-bar { margin: 0; border-radius: 0; flex-wrap: wrap; font-size: 11px; }
  .case-bar p { flex-basis: calc(100% - 80px); }
  .cs-grid { grid-template-columns: 1fr; }
}
@media print { .case-bar { display: none; } }

/* ===== Full-screen fill on desktop: content stretches to the viewport height ===== */
@media (min-width: 1025px) and (min-height: 700px) {
  .app { display: flex; flex-direction: column; }
  .layout { flex: 1; }
  .screen.active { flex: 1; }
  .screen[data-screen="dashboard"] .row1 { flex: 1; }
  .screen[data-screen="dashboard"] .row2 { flex: 1.15; }
  .admissions, .sources, .occupancy { display: flex; flex-direction: column; }
  .admissions .dots { flex: 1; align-content: space-evenly; }
  .dot { max-width: 34px; }
  .sources .sources-body { flex: 1; }
  .sources .chart { height: auto; min-height: 196px; }
  .occupancy .gauge-wrap { margin: auto; max-width: 260px; }
  .occupancy .occ-foot { margin-top: 0; }
  .screen[data-screen="calendar"] .cal-layout { flex: 1; }
}

/* ===== Real photos ===== */
.ph { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: #e9ebef; box-shadow: 0 0 0 2px #fff; }
.ph.md, .ini.md { width: 34px; height: 34px; }
.ph.lg { width: 46px; height: 46px; }
.ph.xl { width: 64px; height: 64px; box-shadow: 0 0 0 3px #fff, 0 10px 22px -10px rgba(16,24,40,.45); }
.ph.center-ph { display: block; margin: 4px auto 14px; }
.avatar { display: block; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s var(--ease); }
.profile:hover .avatar img { transform: scale(1.08); }
.kv b.who { display: flex; align-items: center; gap: 8px; }
.m-head { gap: 12px; margin-bottom: 4px; }
.m-head h3 { margin: 0; }
.m-head .m-sub { margin-bottom: 0; }
.m-banner { display: block; width: calc(100% + 48px); max-width: none; height: 150px; margin: -24px -24px 18px; object-fit: cover; border-radius: 22px 22px 0 0; }

/* Promo card: doctor photo, toned to the card's blue */
.promo-photo {
  position: absolute; right: 0; bottom: 0; width: 66%; height: 100%; object-fit: cover; object-position: center 18%;
  filter: grayscale(1) contrast(1.08) brightness(1.08); mix-blend-mode: luminosity; opacity: .95;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 45%); mask-image: linear-gradient(90deg, transparent 0, #000 45%);
  transition: transform .8s var(--ease);
}
.promo:hover .promo-photo { transform: scale(1.06); }

/* Photo backgrounds on dark cards */
.card-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; transition: transform 1.2s var(--ease); }
.card:hover .card-bg { transform: scale(1.06); }
.card-shade { position: absolute; inset: 0; z-index: 0; background: linear-gradient(90deg, rgba(17,18,22,.97) 0%, rgba(17,18,22,.85) 42%, rgba(17,18,22,.3) 100%); }
.card-shade.dense { background: linear-gradient(180deg, rgba(27,28,33,.8) 0%, rgba(27,28,33,.96) 55%); }
.expiry > :not(.card-bg):not(.card-shade) { position: relative; z-index: 1; }

/* ==========================================================
   Responsive: drawer sidebar (tablet + phone), bottom nav (phone)
   ========================================================== */
.menu-btn, .tab svg, .day-strip, .drawer-scrim { display: none; }

@media (max-width: 1024px) {
  .menu-btn { display: grid; }
  .topbar { flex-wrap: wrap; gap: 12px; }
  .tabs { order: 3; width: 100%; display: grid; grid-template-columns: repeat(5, 1fr); }
  .tab { text-align: center; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 90; width: min(300px, 86vw);
    display: flex; flex-direction: column; align-items: stretch; gap: 22px; padding: 22px 18px 18px;
    background: var(--app); overflow-y: auto; transform: translateX(-105%);
    transition: transform .4s var(--ease); box-shadow: 24px 0 50px -24px rgba(15,23,42,.45);
  }
  body.drawer-open { overflow: hidden; }
  body.drawer-open .sidebar { transform: none; }
  .drawer-scrim { display: block; position: fixed; inset: 0; z-index: 89; background: rgba(15,17,22,.42); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .3s; }
  body.drawer-open .drawer-scrim { opacity: 1; pointer-events: auto; }
  .promo { margin-top: auto; min-height: 150px; flex-shrink: 0; }
}

@media (max-width: 640px) {
  .app { padding: 14px 14px 12px; }
  .topbar { flex-wrap: nowrap; gap: 10px; margin-bottom: 18px; }
  .brand-text { font-size: 15px; }

  /* Bottom navigation */
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 75; width: auto; gap: 2px; overflow: visible;
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0;
    background: rgba(255,255,255,.97); backdrop-filter: blur(12px); box-shadow: 0 -10px 30px -14px rgba(16,24,40,.3);
  }
  .tabs .tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 0 6px; font-size: 10px; font-weight: 500; color: var(--muted); border-radius: 14px; transition: color .25s, background .25s; }
  .tab svg { display: block; width: 20px; height: 20px; }
  .tabs .tab.active { color: var(--blue); background: #eef3ff; }
  .tab-indicator { display: none; }
  .credit { padding: 4px 16px 96px; }
  .toasts { left: 12px; right: 12px; bottom: 92px; align-items: center; }

  .main-head { gap: 12px; }
  .main-head .head-actions { flex-wrap: wrap; }
  .card-head { flex-wrap: wrap; }
  .card-head .search { flex: 1 1 180px; }
  .search input, .search input:focus { width: 100%; }

  /* Invoice + medicine tables become stacked cards */
  .tbl-cards, .tbl-cards tbody { display: block; }
  .tbl-cards thead { display: none; }
  .tbl-cards tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; align-items: center; padding: 12px 6px; border-bottom: 1px solid var(--line); }
  .tbl-cards tbody tr:last-child { border-bottom: 0; }
  .tbl-cards tbody tr.empty { display: block; }
  .tbl-cards td { padding: 0; border: 0; white-space: normal; min-width: 0; }
  .tbl-cards .c-who, .tbl-cards .c-name { grid-column: 1; grid-row: 1; }
  .tbl-cards .c-amt { grid-column: 2; grid-row: 1; font-weight: 600; }
  .tbl-cards .c-dept { grid-column: 1; grid-row: 2; font-size: 11px; color: var(--muted); }
  .tbl-cards .c-st { grid-column: 2; grid-row: 2; justify-self: end; }
  .tbl-cards .c-id, .tbl-cards .c-cat { grid-column: 1; grid-row: 3; font-size: 10.5px; color: var(--muted); }
  .tbl-cards .c-date, .tbl-cards .c-exp { grid-column: 2; grid-row: 3; font-size: 10.5px; color: var(--muted); text-align: right; }
  #medBody .c-st { grid-row: 1; }
  #medBody .c-stock { grid-column: 1; grid-row: 2; }
  #medBody .c-stock .meter { width: 100%; }
  #medBody .c-act { grid-column: 2; grid-row: 2; justify-self: end; }

  /* Schedule: one day at a time with a day picker */
  .day-strip { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 12px; }
  .day-strip button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0; border-radius: 12px; background: var(--app); font-size: 9.5px; color: var(--muted); transition: background .2s, color .2s; }
  .day-strip b { font-size: 14px; font-weight: 500; color: var(--ink); }
  .day-strip button.today b { color: var(--blue); }
  .day-strip button.on { background: var(--ink); color: #c9ccd4; }
  .day-strip button.on b { color: #fff; }
  .sched { grid-template-columns: 44px minmax(0, 1fr); min-width: 0; }
  .sched .dh, .sched .corner { display: none; }
  .sched .day:not(.focus) { display: none; }
  .sched-stats { display: grid; grid-template-columns: 1fr 1fr; }

  /* Popups */
  .modal-card { padding: 20px; border-radius: 20px; }
  .m-banner { width: calc(100% + 40px); margin: -20px -20px 16px; height: 130px; border-radius: 20px 20px 0 0; }
}

/* Phone polish */
.sched-wrap { padding-top: 8px; }
@media (max-width: 640px) {
  .main-head > div:first-child { width: 100%; }
  .main-head .head-actions { display: grid; grid-template-columns: 1.35fr 1fr 1fr; width: 100%; }
  .main-head .head-actions .circle { display: none; }
  .main-head .head-actions .pill { justify-content: center; }
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; gap: 8px; }
  .kpi .val { font-size: 20px; }
  .kpi .label { font-size: 10.5px; }
  .kpi-ic { width: 26px; height: 26px; }
  .kpi .spark svg { width: 52px; height: 22px; }
  .line-chart text { font-size: 10px; }
}
@media (max-width: 340px) {
  .kpi-row { grid-template-columns: 1fr; }
}
