/* View-specific: kanban, journey rail, timeline, record, WhatsApp,
   scheduler, automation flow, charts. */

/* ── Kanban ────────────────────────────────────────────────── */
.kanban {
  display: flex; gap: var(--s3); overflow-x: auto;
  padding-bottom: var(--s3); align-items: flex-start;
  scroll-snap-type: x proximity;
}
.kcol {
  flex: 0 0 278px; scroll-snap-align: start;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); display: flex; flex-direction: column;
  max-height: 68vh;
  transition: background var(--d-base) var(--ease), box-shadow var(--d-base) var(--ease);
}
.kcol-head { padding: 11px var(--s3) 9px; border-bottom: 1px solid var(--border); }
.kcol-title { display: flex; align-items: center; gap: var(--s2); }
.kcol-title .dot { width: 8px; height: 8px; border-radius: 99px; background: var(--s, var(--brand)); flex: none; }
.kcol-title strong { font-size: var(--t-sm); font-weight: 650; flex: 1; }
.kcol-title .count {
  font-size: 10.5px; color: var(--fg-3); font-variant-numeric: tabular-nums;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 99px; padding: 1px 7px;
}
/* Share-of-pipeline micro bar under each column header */
.kcol-meter { height: 3px; border-radius: 99px; background: var(--surface-3); margin-top: 9px; overflow: hidden; }
.kcol-meter > span { display: block; height: 100%; background: var(--s, var(--brand)); border-radius: 99px; transition: width var(--d-slow) var(--ease); }
.kcol-body { padding: var(--s2); display: flex; flex-direction: column; gap: var(--s2); overflow-y: auto; min-height: 64px; }
.kcol.drop { background: var(--brand-soft); box-shadow: inset 0 0 0 2px var(--brand); }

.kcard {
  position: relative;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 11px 12px;
  cursor: grab; box-shadow: var(--e1);
  animation: cardIn var(--d-slow) var(--ease) both; animation-delay: var(--i, 0ms);
  transition: box-shadow var(--d-base) var(--ease), transform var(--d-base) var(--ease), border-color var(--d-base) var(--ease);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(8px) } }
.kcard:hover { box-shadow: var(--e3); transform: translateY(-2px); border-color: var(--border-strong); }
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .4; transform: rotate(1.5deg) scale(.98); box-shadow: var(--e4); }
.kcard .kc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s2); }
.kcard strong { font-size: var(--t-md); }
.kcard .kc-line { font-size: var(--t-xs); color: var(--fg-3); margin-top: 3px; }
.kcard .kc-cond { font-size: var(--t-sm); color: var(--fg-2); margin-top: 7px; line-height: 1.45; }
.kcard .kc-foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* ── Journey rail ──────────────────────────────────────────── */
.flow-rail { display: flex; gap: 0; overflow-x: auto; padding: var(--s1) 0 var(--s4); }
.fstep { flex: 1 0 158px; position: relative; padding: 0 7px; }
.fstep .bar {
  height: 6px; border-radius: 99px; background: var(--s);
  transform-origin: left; animation: barIn var(--d-slow) var(--ease) both; animation-delay: var(--i, 0ms);
}
@keyframes barIn { from { transform: scaleX(0) } }
.fstep .fs-body { padding: var(--s3) 2px 0; }
.fstep .fs-n {
  font-family: var(--display); font-size: 30px; line-height: 1;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.fstep .fs-t { font-size: var(--t-sm); font-weight: 650; margin-top: 5px; }
.fstep .fs-d { font-size: var(--t-xs); color: var(--fg-3); margin-top: 4px; line-height: 1.5; }
.fstep .fs-conv { font-size: var(--t-xs); color: var(--brand-text); font-weight: 650; margin-top: 7px; }
.flow-rail.compact { overflow: visible; gap: var(--s2); }
.flow-rail.compact .fstep { flex: 1 1 0; min-width: 0; padding: 0; }
.flow-rail.compact .fs-t { font-size: var(--t-xs); }

/* Below ~1100px the ten labels can no longer share one row without colliding,
   so the compact rail goes back to scrolling at a legible width. */
@media (max-width: 1100px) {
  .flow-rail.compact { overflow-x: auto; gap: var(--s3); }
  .flow-rail.compact .fstep { flex: 0 0 104px; }
}
a.fstep { border-radius: var(--r-xs); transition: transform var(--d-base) var(--ease); }
a.fstep:hover { transform: translateY(-2px); }

/* ── Timeline ──────────────────────────────────────────────── */
.timeline { position: relative; padding-left: var(--s6); }
.timeline::before {
  content: ''; position: absolute; left: 7px; top: 8px; bottom: 8px;
  width: 2px; border-radius: 2px;
  background: linear-gradient(180deg, var(--border), var(--border) 70%, transparent);
}
.tl-item { position: relative; padding-bottom: var(--s5); animation: cardIn var(--d-slow) var(--ease) both; animation-delay: var(--i, 0ms); }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ''; position: absolute; left: calc(var(--s6) * -1 + 2px); top: 4px;
  width: 12px; height: 12px; border-radius: 99px;
  background: var(--surface-1); border: 2px solid var(--d, var(--brand));
  box-shadow: 0 0 0 3px var(--surface-1);
}
.tl-item.done::before { background: var(--d, var(--brand)); }
.tl-head { display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap; }
.tl-head strong { font-size: var(--t-md); }
.tl-head time { font-size: var(--t-xs); color: var(--fg-3); }
.tl-note { font-size: var(--t-sm); color: var(--fg-2); margin-top: 4px; }

/* ── Patient record ────────────────────────────────────────── */
.rec-hero {
  display: flex; gap: var(--s4); align-items: flex-start; padding: var(--s5);
  background: linear-gradient(140deg, var(--surface-2), var(--surface-1) 55%);
  border-radius: var(--r) var(--r) 0 0;
}
.rec-hero h2 { font-family: var(--display); font-size: var(--t-2xl); font-weight: 400; letter-spacing: -.018em; }
.rec-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.fields {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 1px; background: var(--border); border-top: 1px solid var(--border);
  border-radius: 0 0 var(--r) var(--r); overflow: hidden;
}
.field { background: var(--surface-1); padding: 11px var(--s5); }
.field .f-k { font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--fg-3); font-weight: 650; }
.field .f-v { font-size: var(--t-md); margin-top: 3px; }
@media (max-width: 1100px) { .fields { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 620px)  { .fields { grid-template-columns: 1fr; } }

.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--border);
  margin-bottom: var(--s4); overflow-x: auto;
}
.tabs button {
  position: relative; border: 0; background: transparent;
  min-height: 42px; padding: 0 var(--s4); cursor: pointer;
  font-size: var(--t-md); color: var(--fg-3); white-space: nowrap;
  transition: color var(--d-fast) var(--ease);
}
.tabs button:hover { color: var(--fg); }
.tabs button.on { color: var(--brand-text); font-weight: 600; }
.tabs button.on::after {
  content: ''; position: absolute; left: var(--s3); right: var(--s3); bottom: -1px;
  height: 2px; background: var(--brand); border-radius: 2px 2px 0 0;
  animation: tabIn var(--d-base) var(--ease);
}
@keyframes tabIn { from { transform: scaleX(0) } }

.session-dots { display: flex; gap: 5px; flex-wrap: wrap; }
.sdot {
  width: 28px; height: 28px; border-radius: var(--r-xs);
  display: grid; place-items: center;
  font-size: 10.5px; font-weight: 650; font-variant-numeric: tabular-nums;
  border: 1px solid var(--border-strong); color: var(--fg-3); background: var(--surface-1);
  animation: cardIn var(--d-base) var(--ease) both; animation-delay: var(--i, 0ms);
}
.sdot.done { background: var(--brand); border-color: var(--brand); color: var(--brand-on); }
.sdot.next { border-color: var(--brand); border-style: dashed; color: var(--brand-text); }

/* ── WhatsApp ──────────────────────────────────────────────── */
.wa-layout {
  display: grid; grid-template-columns: 300px minmax(0,1fr);
  border: 1px solid var(--border); border-radius: var(--r);
  overflow: hidden; background: var(--surface-1); box-shadow: var(--e2);
  height: clamp(460px, calc(100vh - 300px), 720px);
}
.wa-list { border-right: 1px solid var(--border); overflow-y: auto; }
.wa-item {
  display: flex; gap: 10px; padding: 12px var(--s3);
  border-bottom: 1px solid var(--border); cursor: pointer;
  border-left: 3px solid transparent;
  transition: background var(--d-fast) var(--ease), border-color var(--d-fast) var(--ease);
}
.wa-item:hover { background: var(--surface-2); }
.wa-item.on { background: var(--brand-soft); border-left-color: var(--brand); }
.wa-i-body { min-width: 0; flex: 1; }
.wa-item strong { font-size: var(--t-md); display: block; }
.wa-item .prev { font-size: var(--t-xs); color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.wa-thread { display: flex; flex-direction: column; min-width: 0; }
.wa-head { padding: 11px var(--s4); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.wa-body {
  flex: 1; overflow-y: auto; padding: var(--s5);
  display: flex; flex-direction: column; gap: 9px;
  background: var(--bg);
  background-image: radial-gradient(var(--border) .8px, transparent .8px);
  background-size: 16px 16px;
}
.bubble {
  max-width: 70%; padding: 9px 12px; border-radius: var(--r);
  font-size: var(--t-md); box-shadow: var(--e1);
  animation: bubbleIn var(--d-base) var(--ease) both;
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(6px) scale(.98) } }
.bubble time { display: block; font-size: 10px; color: var(--fg-3); margin-top: 5px; }
.bubble.out { align-self: flex-end; background: var(--wa-soft); border: 1px solid var(--border); border-bottom-right-radius: 4px; }
.bubble.in  { align-self: flex-start; background: var(--surface-1); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble .tpl {
  font-size: 9.5px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--fg-3); font-weight: 650; margin-bottom: 4px;
}
.tpl-strip { display: flex; gap: 6px; padding: var(--s2) var(--s3) 0; flex-wrap: wrap; background: var(--surface-1); align-items: center; }
.wa-compose { border-top: 1px solid var(--border); padding: 10px var(--s3); display: flex; gap: var(--s2); background: var(--surface-1); }
.wa-compose input {
  flex: 1; min-height: 40px; padding: 0 var(--s4);
  border: 1px solid var(--border-strong); border-radius: 99px;
  background: var(--surface-1); outline: none;
  transition: border-color var(--d-fast) var(--ease), box-shadow var(--d-fast) var(--ease);
}
.wa-compose input:focus-visible { border-color: var(--wa); box-shadow: 0 0 0 3px var(--wa-soft); outline: none; }
.wa-compose .btn { border-radius: 99px; padding: 0 var(--s4); }
@media (max-width: 900px) { .wa-layout { grid-template-columns: 1fr; height: auto; } .wa-list { max-height: 240px; border-right: 0; border-bottom: 1px solid var(--border); } }

/* ── Automations ───────────────────────────────────────────── */
.auto-row {
  display: grid; grid-template-columns: 44px minmax(0,1.2fr) minmax(0,2fr) 120px 84px;
  gap: var(--s3); align-items: center;
  padding: var(--s3) var(--s5); border-bottom: 1px solid var(--border);
  transition: background var(--d-fast) var(--ease);
}
.auto-row:last-child { border-bottom: 0; }
.auto-row:hover { background: var(--surface-2); }
.auto-name { font-size: var(--t-md); font-weight: 600; }
.auto-cat { font-size: var(--t-xs); color: var(--fg-3); margin-top: 2px; }
.pipe { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: var(--t-xs); }
.pnode { padding: 4px 9px; border-radius: var(--r-xs); background: var(--surface-3); border: 1px solid var(--border); white-space: nowrap; }
.pnode.trigger { background: var(--ochre-soft); border-color: transparent; color: var(--ochre-text); }
.pnode.cond    { background: var(--info-soft);  border-color: transparent; color: var(--info-text); }
.pnode.act     { background: var(--brand-soft); border-color: transparent; color: var(--brand-text); }
.pnode.wa      { background: var(--wa-soft);    border-color: transparent; color: var(--wa-text); }
.arrow { color: var(--border-strong); }
@media (max-width: 1100px) { .auto-row { grid-template-columns: 44px 1fr; row-gap: var(--s2); } .auto-row .pipe { grid-column: 2; } }

.flow-canvas { display: flex; align-items: stretch; overflow-x: auto; padding: var(--s1) 0 var(--s3); }
.fnode {
  flex: 0 0 196px; padding: var(--s3) var(--s3) var(--s4);
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface-1); box-shadow: var(--e1);
  animation: cardIn var(--d-slow) var(--ease) both; animation-delay: var(--i, 0ms);
  transition: box-shadow var(--d-base) var(--ease), transform var(--d-base) var(--ease);
}
.fnode:hover { box-shadow: var(--e3); transform: translateY(-2px); }
.fnode .fn-kind { font-size: 9.5px; letter-spacing: .09em; text-transform: uppercase; font-weight: 700; color: var(--fg-3); }
.fnode .fn-title { font-size: var(--t-sm); font-weight: 650; margin-top: 6px; }
.fnode .fn-desc { font-size: var(--t-xs); color: var(--fg-3); margin-top: 5px; line-height: 1.5; }
.fnode.t-trigger { border-top: 3px solid var(--ochre); }
.fnode.t-wait    { border-top: 3px solid var(--border-strong); }
.fnode.t-cond    { border-top: 3px solid var(--info); }
.fnode.t-action  { border-top: 3px solid var(--brand); }
.fconn { flex: 0 0 32px; display: grid; place-items: center; color: var(--border-strong); }

/* ── Scheduler ─────────────────────────────────────────────── */
.sched {
  display: grid; grid-template-columns: 138px repeat(6, minmax(96px,1fr));
  border: 1px solid var(--border); border-radius: var(--r);
  overflow: hidden; background: var(--surface-1); font-size: var(--t-sm);
  box-shadow: var(--e1);
}
.sched > div { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: var(--s2) 9px; min-height: 52px; }
.sched .sh {
  background: var(--surface-2); font-weight: 650; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .06em; color: var(--fg-3); min-height: 0;
}
.sched .room { background: var(--surface-2); display: flex; flex-direction: column; justify-content: center; }
.sched .room strong { font-size: var(--t-sm); font-weight: 650; }
.sched .room span { font-size: 10.5px; color: var(--fg-3); }
.slot { display: flex; flex-direction: column; gap: 3px; }
.book {
  border-radius: var(--r-xs); padding: 6px 8px; font-size: var(--t-xs); line-height: 1.4;
  border-left: 3px solid var(--b, var(--brand)); background: var(--bk, var(--surface-3));
  transition: transform var(--d-fast) var(--ease), box-shadow var(--d-fast) var(--ease);
}
.book[data-action] { cursor: pointer; }
.book[data-action]:hover { transform: translateY(-1px); box-shadow: var(--e2); }
.book strong { display: block; font-size: var(--t-xs); font-weight: 650; }
.book span { color: var(--fg-2); }
.free { color: var(--fg-3); font-size: 10.5px; opacity: .5; }

/* ── Charts ────────────────────────────────────────────────── */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--fg-3); font-size: 10px; font-family: var(--sans); }
.chart .series-line { fill: none; stroke: var(--brand); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart .series-area { fill: url(#areaGrad); }
.chart .pt { fill: var(--surface-1); stroke: var(--brand); stroke-width: 2.5; transition: r var(--d-fast) var(--ease); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .pt, .chart .hit:focus-visible + .pt { r: 6; }
.chart .hit:hover ~ .val, .chart .hit:focus-visible ~ .val { opacity: 1; }
.chart .val { opacity: 0; transition: opacity var(--d-fast) var(--ease); }
.chart .val rect { fill: var(--fg); rx: 5; }
.chart .val text { fill: var(--bg); font-size: 10.5px; font-weight: 650; font-family: var(--sans); }
.chart .bar-seg { transition: opacity var(--d-fast) var(--ease); }
.chart .bar-seg:hover { opacity: .82; }

.legend { display: flex; gap: var(--s4); flex-wrap: wrap; font-size: var(--t-xs); color: var(--fg-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; background: var(--c); flex: none; }

.donut-wrap { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; }
.donut-center { font-family: var(--display); font-size: 22px; fill: var(--fg); text-anchor: middle; }
.donut-sub { fill: var(--fg-3); font-size: 10px; text-anchor: middle; font-family: var(--sans); }
