/* Sahaya Inbox · dunia Lembar Konsultasi untuk permukaan kerja klinik */

:root {
  --paper: #f7f8fa;
  --sheet: #ffffff;
  --thread: #fafafb;
  --ink: #0c1322;
  --ink-hover: #1b2439;
  --ink-2: #3a4253;
  --ink-3: #5e6676;
  --rule: rgba(12, 19, 34, 0.1);
  --rule-2: rgba(12, 19, 34, 0.18);
  --rule-3: rgba(12, 19, 34, 0.34);
  --marker: #5b3cc4;
  --marker-2: #4a2fa6;
  --marker-wash: rgba(91, 60, 196, 0.09);
  --blush: #f6e3dc;
  --blush-ink: #7a3b2a;
  --blush-dot: #c0664a;
  --lilac: #ece7fa;
  --lilac-ink: #4a2fa6;
  --amber: #fbebcf;
  --amber-ink: #7a4e0b;
  --amber-dot: #c98a1b;
  --sky: #e3ecf6;
  --alert: #a3372b;
  /* Grafik laporan owner: turunan tint sky, lolos validator (terang, kroma, kontras). */
  --chart-bar: var(--ink-2);
  --chart-bar-hover: var(--ink-hover);
  --chart-band: #eef3f9;
  --chart-grid: rgba(12, 19, 34, 0.08);

  --serif: 'Hedvig Letters Serif', Georgia, 'Times New Roman', serif;
  --sans: 'Public Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --shadow-rest: 0 1px 2px rgba(12, 19, 34, 0.05), 0 14px 34px -14px rgba(12, 19, 34, 0.16);
  --shadow-lift: 0 2px 4px rgba(12, 19, 34, 0.06), 0 28px 56px -24px rgba(12, 19, 34, 0.26);
  --shadow-pill: 0 1px 1px rgba(12, 19, 34, 0.2), 0 10px 24px -12px rgba(12, 19, 34, 0.6);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(91, 60, 196, 0.2);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--marker);
  outline-offset: 3px;
  border-radius: 8px;
}

input,
textarea,
button,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

h1,
h2,
h3,
p {
  text-wrap: pretty;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(12, 19, 34, 0.22) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(12, 19, 34, 0.2);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}

.figure {
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--ink-3);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 60;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.boot {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink-3);
  font-size: 14px;
}

/* ===== Kerangka aplikasi ===== */

#app {
  height: 100%;
}

.app {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  grid-template-areas: 'nav stage';
  height: 100dvh;
}

.stage {
  grid-area: stage;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  outline: none;
}

.stage > .notice {
  margin: 12px 16px 0;
}

.topbar {
  display: none;
}

.rail {
  grid-area: nav;
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 18px 0 16px;
  border-right: 1px solid var(--rule);
  background: var(--paper);
}

.rail-brand {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--ink);
}

.rail-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rail-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 68px;
  padding: 10px 4px 8px;
  border-radius: 12px;
  color: var(--ink-3);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  transition:
    background-color 0.2s var(--ease),
    color 0.2s var(--ease);
}

.rail-link:hover {
  color: var(--ink);
  background: rgba(12, 19, 34, 0.04);
}

.rail-link.is-active {
  color: var(--ink);
  background: var(--marker-wash);
}

.rail-link.is-active .rail-icon {
  color: var(--marker-2);
}

.rail-icon {
  position: relative;
  display: grid;
  place-items: center;
}

.rail-count {
  position: absolute;
  top: -7px;
  right: -13px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 19px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--paper);
}

.rail-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.wa-state {
  display: grid;
  justify-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-3);
  text-align: center;
  max-width: 76px;
}

.wa-state .state-dot {
  width: 8px;
  height: 8px;
}

.wa-state.is-on .state-dot {
  background: var(--ink-2);
}

.wa-state.is-off .state-dot {
  background: var(--amber-dot);
}

.user-menu {
  position: relative;
}

.avatar-btn {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 50%;
}

.menu {
  position: absolute;
  left: calc(100% + 12px);
  bottom: 0;
  z-index: 30;
  width: 248px;
  padding: 8px;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 16px;
  box-shadow: var(--shadow-lift);
  animation: rise 0.18s var(--ease) both;
}

.menu-who {
  display: grid;
  gap: 2px;
  margin: 0 0 6px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--rule);
  font-size: 12.5px;
  color: var(--ink-3);
}

.menu-who strong {
  font-size: 14px;
  color: var(--ink);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}

.menu-item:hover {
  background: rgba(12, 19, 34, 0.05);
}

/* ===== Elemen dasar ===== */

.sheet {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 18px;
  box-shadow: var(--shadow-rest);
}

.view-title {
  margin: 0;
  font: 400 27px/1.1 var(--serif);
  letter-spacing: -0.015em;
}

.column-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--ink-3);
}

.tag-example {
  display: inline-flex;
  padding: 2px 9px;
  border: 1px dashed var(--rule-3);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
}

.count {
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 26px;
  text-align: center;
}

.unread {
  flex: none;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.avatar {
  --size: 36px;
  flex: none;
  display: grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  overflow: hidden;
  border-radius: 50%;
  background: var(--sheet);
  border: 1px solid var(--rule-2);
  color: var(--ink-2);
  font-size: calc(var(--size) * 0.36);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.icon {
  flex: none;
}

.state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  white-space: nowrap;
}

.state-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rule-3);
}

.state--bot .state-dot {
  background: var(--blush-dot);
}

.state--diambil_alih .state-dot,
.state--perlu_admin .state-dot {
  background: var(--amber-dot);
}

.state--record .state-dot {
  background: var(--lilac-ink);
}

/* Tombol: pil tinta, garis tipis, dan teks. Violet hanya untuk fokus dan tanda. */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background-color 0.2s var(--ease),
    border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease),
    translate 0.2s var(--ease);
}

.btn-ink {
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-pill);
}

.btn-ink:hover:not(:disabled) {
  background: var(--ink-hover);
  translate: 0 -1px;
}

.btn-ink:active:not(:disabled) {
  translate: 0 0;
}

.btn-outline {
  background: var(--sheet);
  color: var(--ink);
  border-color: var(--rule-2);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--ink);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-sm {
  min-height: 36px;
  padding: 8px 14px;
  font-size: 13.5px;
}

.btn-block {
  width: 100%;
}

.btn-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 2px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--rule-3);
  text-underline-offset: 3px;
  justify-self: start;
}

.btn-text:hover:not(:disabled) {
  color: var(--ink);
  text-decoration-color: var(--ink);
}

.btn-text--quiet {
  color: var(--ink-3);
}

.btn-text:disabled {
  opacity: 0.5;
}

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-2);
}

.icon-btn:hover {
  background: rgba(12, 19, 34, 0.05);
  color: var(--ink);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.pill--small {
  padding: 2px 8px;
  font-size: 11px;
}

.pill--record {
  background: var(--lilac);
  color: var(--lilac-ink);
}

.pill--staff {
  background: var(--amber);
  color: var(--amber-ink);
}

.pill--staff-outline {
  border-color: rgba(122, 78, 11, 0.4);
  color: var(--amber-ink);
}

.pill--dashed {
  border: 1px dashed var(--rule-3);
  color: var(--ink-3);
}

.pill--muted {
  border-color: var(--rule-2);
  color: var(--ink-3);
}

.pill--done {
  border-color: var(--ink);
  color: var(--ink);
}

/* Pilihan: garis putus-putus sampai dipilih, lalu padat violet. */

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.segment,
.tab {
  padding: 7px 12px;
  border: 1px dashed var(--rule-3);
  border-radius: 10px;
  background: var(--sheet);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition:
    border-color 0.15s var(--ease),
    background-color 0.15s var(--ease);
}

.segment:hover,
.tab:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}

.segment[aria-pressed='true'],
.tab.is-active {
  border: 1px solid var(--marker);
  background: linear-gradient(var(--marker-wash), var(--marker-wash)) var(--sheet);
  color: var(--ink);
  font-weight: 600;
}

/* Isian: garis bawah saja, fokus menjadi violet. */

.field {
  width: 100%;
  padding: 9px 2px;
  border: 0;
  border-bottom: 1.5px solid var(--rule-2);
  border-radius: 0;
  background: transparent;
  font-size: 15px;
  font-weight: 500;
  caret-color: var(--marker);
  transition: border-color 0.2s var(--ease);
}

.field:focus,
.field:focus-visible {
  outline: none;
  border-bottom-color: var(--marker);
}

.field::placeholder {
  color: var(--ink-3);
  font-weight: 400;
}

.field:disabled {
  color: var(--ink-3);
  cursor: not-allowed;
}

.field--area {
  line-height: 1.5;
  resize: vertical;
}

.field-label {
  display: grid;
  gap: 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.field-group-label {
  margin: 0;
  padding: 0;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.check {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
}

.check input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.check-box {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border: 1px dashed var(--rule-3);
  border-radius: 4px;
  background: var(--sheet);
  color: transparent;
  transition:
    background-color 0.15s var(--ease),
    border-color 0.15s var(--ease);
}

.check input:checked + .check-box {
  border: 1px solid var(--marker);
  background: var(--marker);
  color: #fff;
}

.check input:focus-visible + .check-box {
  outline: 2px solid var(--marker);
  outline-offset: 2px;
}

.form-error,
.is-alert {
  color: var(--alert);
}

.form-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  font-size: 13.5px;
  font-weight: 500;
}

.form-error .icon {
  margin-top: 2px;
}

.inline-error {
  display: grid;
  gap: 4px;
  margin: 12px 4px;
  padding: 12px 14px;
  border: 1px solid rgba(163, 55, 43, 0.3);
  border-radius: 14px;
  background: var(--sheet);
}

.inline-error p {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  color: var(--alert);
  font-size: 13.5px;
  font-weight: 500;
}

.empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  max-width: 380px;
  margin: 0 auto;
  padding: 44px 24px;
  text-align: center;
}

.empty-title {
  margin: 0;
  font: 400 22px/1.2 var(--serif);
  color: var(--ink);
}

.empty-text {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--ink-2);
}

.skeleton {
  display: grid;
  gap: 8px;
  padding: 4px 0;
}

.skeleton-slip,
.skeleton-row,
.skeleton-qr,
.sk-bubble,
.sk-line {
  display: block;
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(12, 19, 34, 0.04), rgba(12, 19, 34, 0.08), rgba(12, 19, 34, 0.04));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.skeleton-slip {
  height: 88px;
}

.skeleton-row {
  height: 58px;
}

.skeleton-qr {
  width: 240px;
  height: 240px;
}

.is-refreshing {
  opacity: 0.55;
  transition: opacity 0.2s var(--ease);
}

/* Cap TERCATAT: cincin ganda violet, miring -14 derajat, ditekan sekali. */

.stamp {
  --stamp: 96px;
  flex: none;
  display: grid;
  place-items: center;
  width: var(--stamp);
  height: var(--stamp);
  border: 2px solid var(--marker);
  border-radius: 50%;
  color: var(--marker);
  rotate: -14deg;
  opacity: 0.92;
}

.stamp-ring {
  display: grid;
  place-items: center;
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  padding: 0 4px;
  border: 1px solid rgba(91, 60, 196, 0.55);
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.05em;
  text-align: center;
  text-transform: uppercase;
}

.stamp--small {
  --stamp: 74px;
}

.stamp--small .stamp-ring {
  font-size: 7px;
  letter-spacing: 0.03em;
}

.slip-sheet-head .stamp {
  margin: -4px 8px 0 0;
}

.stamp.is-pressing {
  animation: stamp-press 0.18s var(--ease) both;
}

/* ===== Meja kerja (antrean, percakapan, panel) ===== */

.desk {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 356px minmax(0, 1fr) 348px;
}

.column {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.queue {
  border-right: 1px solid var(--rule);
}

.column-head {
  display: grid;
  gap: 12px;
  padding: 22px 20px 12px;
}

.column-head > .column-meta {
  margin-top: -6px;
}

.column-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.column-scroll {
  flex: 1;
  overflow: auto;
  padding: 0 16px 28px;
}

.detail {
  padding: 14px;
}

.panel {
  border-left: 1px solid var(--rule);
}

.panel-scroll {
  height: 100%;
  overflow: auto;
  padding: 20px 20px 32px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-3);
}

.search .field {
  font-weight: 400;
}

.slip-group {
  margin-top: 14px;
}

.group-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 2px 10px;
  padding-top: 12px;
  border-top: 1px solid var(--ink);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.slip-list,
.thread-list,
.mini-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.slip-list {
  display: grid;
  gap: 8px;
}

.slip-list--page {
  padding: 4px 0 24px;
}

.slip-item {
  display: grid;
  grid-template-rows: 1fr;
  transition:
    grid-template-rows 0.24s var(--ease) 0.8s,
    opacity 0.24s var(--ease) 0.8s,
    margin 0.24s var(--ease) 0.8s;
}

.slip-item > .slip {
  min-height: 0;
  overflow: hidden;
}

.slip-item.is-leaving {
  grid-template-rows: 0fr;
  opacity: 0;
  margin-top: -8px;
}

.slip {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 12px 14px 11px;
  border: 1px dashed var(--rule-3);
  border-radius: 14px;
  background: var(--sheet);
  color: var(--ink);
  text-decoration: none;
  transition:
    border-color 0.2s var(--ease),
    background-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.slip:hover {
  border-color: var(--ink-3);
  box-shadow: var(--shadow-rest);
}

.slip.is-selected {
  border: 1px solid var(--marker);
  background: linear-gradient(var(--marker-wash), var(--marker-wash)) var(--sheet);
}

.slip.is-handled,
.slip.is-solid {
  border-style: solid;
  border-color: var(--rule-2);
}

.slip.is-handled {
  border-color: var(--marker);
}

.slip-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.slip-name {
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slip-age {
  flex: none;
  font-size: 12px;
  color: var(--ink-3);
}

.slip-body {
  display: -webkit-box;
  overflow: hidden;
  font-size: 13.5px;
  color: var(--ink-2);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.slip-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.slip-price {
  color: var(--ink-2);
}

.slip .stamp {
  position: absolute;
  right: 12px;
  top: 50%;
  translate: 0 -50%;
}

.detail-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
}

.detail-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.detail-pane {
  flex: 1;
  min-height: 0;
}

.detail-pane > .panel-scroll {
  border-radius: 18px;
}

/* Slip (panel kanan) */

.slip-sheet {
  display: grid;
  gap: 18px;
}

.slip-sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  min-height: 60px;
}

.slip-sheet-head > div {
  min-width: 0;
}

.panel-title {
  margin: 0;
  font: 400 24px/1.15 var(--serif);
  letter-spacing: -0.015em;
}

.panel-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-3);
}

.panel-note {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-2);
}

.ledger {
  margin: 0;
  border-top: 1px solid var(--ink);
}

.ledger > div {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}

.ledger dt {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.ledger dd {
  margin: 0;
  font-size: 14.5px;
  overflow-wrap: anywhere;
}

.slip-fields {
  display: grid;
  gap: 16px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.slip-fields legend {
  float: left;
  width: 100%;
  margin-bottom: -4px;
}

.field-pair {
  clear: both;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 16px;
}

.slip-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.handoff-quote {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--amber);
}

.handoff-quote .field-group-label {
  color: var(--amber-ink);
}

.handoff-quote p {
  margin: 0;
  font-size: 14.5px;
}

.panel-section {
  display: grid;
  gap: 8px;
}

.mini-list {
  border-top: 1px solid var(--rule);
}

.mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
}

.mini-row:hover .mini-row-title {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.mini-row-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
}

.mini-row-title {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-row-sub {
  font-size: 12.5px;
  color: var(--ink-3);
}

/* ===== Percakapan ===== */

.conversation {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.conversation.is-empty {
  justify-content: center;
}

.conv-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule);
}

.conv-who {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
}

.conv-name {
  margin: 0;
  overflow: hidden;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  margin: 0;
  font-size: 13px;
  color: var(--ink-3);
}

.conv-actions {
  flex: none;
  display: flex;
  gap: 8px;
}

.thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
  padding: 16px 20px 14px;
  background: var(--thread);
  overscroll-behavior: contain;
}

.thread-more {
  align-self: center;
}

.thread-empty {
  align-self: center;
  margin: auto 0;
  color: var(--ink-3);
  font-size: 14px;
}

.thread-day {
  align-self: center;
  margin: 14px 0 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.thread-record {
  align-self: center;
  margin: 6px 0;
  max-width: 100%;
}

.thread-record .pill {
  white-space: normal;
  text-align: center;
}

.bubble-row {
  display: flex;
}

.bubble-row.is-out {
  justify-content: flex-end;
}

.bubble {
  max-width: min(560px, 78%);
  padding: 8px 11px 6px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  animation: rise 0.3s var(--ease) both;
}

.bubble--patient {
  border: 1px solid var(--rule);
  border-top-left-radius: 5px;
  background: var(--sheet);
}

.bubble--assistant {
  border-top-right-radius: 5px;
  background: var(--blush);
}

.bubble--admin,
.bubble--admin_phone {
  border-top-right-radius: 5px;
  background: var(--amber);
}

.bubble-label {
  display: block;
  margin-bottom: 1px;
  font-size: 11.5px;
  font-weight: 600;
}

.bubble--assistant .bubble-label {
  color: var(--blush-ink);
}

.bubble--admin .bubble-label,
.bubble--admin_phone .bubble-label {
  color: var(--amber-ink);
}

.bubble-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble-time {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--ink-3);
  text-align: right;
}

.bubble--assistant .bubble-time {
  color: var(--blush-ink);
}

.bubble--admin .bubble-time,
.bubble--admin_phone .bubble-time {
  color: var(--amber-ink);
}

.bubble.is-pending {
  opacity: 0.7;
}

.bubble-media {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 4px;
  padding: 4px 9px;
  border: 1px dashed var(--rule-3);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink-2);
  font-size: 12.5px;
}

.thread-skeleton {
  display: grid;
  gap: 10px;
}

.sk-bubble {
  width: 58%;
  height: 54px;
}

.sk-bubble.is-out {
  justify-self: end;
}

.sk-bubble.is-short {
  width: 36%;
  height: 38px;
}

.sk-line {
  height: 12px;
  border-radius: 6px;
}

.sk-line.is-name {
  width: 140px;
  height: 15px;
}

.sk-line.is-sub {
  width: 220px;
}

.composer {
  padding: 12px 18px 14px;
  border-top: 1px solid var(--rule);
  background: var(--sheet);
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
}

.composer-input {
  flex: 1;
  min-height: 42px;
  max-height: 168px;
  resize: none;
  font-weight: 400;
}

.composer-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--ink-3);
}

.composer-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 500;
}

/* ===== Daftar percakapan ===== */

.thread-list {
  display: grid;
  gap: 2px;
  padding-top: 8px;
}

.thread-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding: 11px 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--ink);
  text-decoration: none;
}

.thread-row:hover {
  background: rgba(12, 19, 34, 0.035);
}

.thread-row.is-selected {
  border-color: rgba(91, 60, 196, 0.4);
  background: var(--marker-wash);
}

.thread-row-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3px;
  min-width: 0;
}

.thread-row-top,
.thread-row-bottom {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.thread-row-name {
  overflow: hidden;
  font-size: 14.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-row-time {
  flex: none;
  font-size: 12px;
  color: var(--ink-3);
}

.thread-row-preview {
  overflow: hidden;
  font-size: 13.5px;
  color: var(--ink-3);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-row.is-unread .thread-row-preview {
  color: var(--ink);
  font-weight: 500;
}

.thread-row-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

/* ===== Booking ===== */

.bookings {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
}

.bookings-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 24px 0;
}

.bookings-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

.bookings-total {
  margin: 0;
  font-size: 14px;
  color: var(--ink-2);
}

.bookings-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.bookings-panel {
  border-left: 1px solid var(--rule);
}

.ledger-table {
  flex: 1;
  min-height: 0;
  margin-bottom: 24px;
  overflow: auto;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 20px;
  box-shadow: var(--shadow-rest);
}

.ledger-table table,
.treatments table,
.chart-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.ledger-table th,
.treatments th,
.chart-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 11px 14px;
  border-bottom: 1px solid var(--rule-2);
  background: var(--paper);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.ledger-table td,
.treatments td,
.chart-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}

.ledger-table tbody tr {
  position: relative;
}

.ledger-table tbody tr:hover {
  background: rgba(12, 19, 34, 0.025);
}

.ledger-table tbody tr.is-selected {
  background: var(--marker-wash);
}

.row-link {
  display: block;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.row-link::after {
  content: '';
  position: absolute;
  inset: 0;
}

.row-link:focus-visible {
  outline: none;
}

.row-link:focus-visible::after {
  outline: 2px solid var(--marker);
  outline-offset: -3px;
  border-radius: 10px;
}

.cell-sub {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
}

.ledger-table td.figure,
.ledger-table td.num {
  white-space: nowrap;
}

.num {
  text-align: right;
}

th.num {
  text-align: right;
}

.overlay-sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  animation: rise 0.2s var(--ease) both;
}

.overlay-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
}

.overlay-title {
  font-size: 15px;
  font-weight: 600;
}

/* ===== Ringkasan ===== */

.overview {
  flex: 1;
  overflow: auto;
  padding: 22px clamp(16px, 3vw, 32px) 44px;
}

.overview-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
}

.overview-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

.overview-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.report {
  padding: 4px 28px;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 44px;
}

.report-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 18px;
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
}

.report-grid > div > .report-row:last-child {
  border-bottom: 0;
}

.report-label {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.report-sub {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-3);
}

.report-value {
  margin: 0;
  font: 400 31px/1 var(--serif);
  letter-spacing: -0.01em;
  text-align: right;
  white-space: nowrap;
}

.report-value small {
  margin-left: 6px;
  font: 400 13px/1 var(--sans);
  color: var(--ink-3);
}

.charts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.chart-card {
  margin: 0;
  padding: 18px 20px 14px;
}

.chart-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.chart-sub {
  margin: 3px 0 12px;
  font-size: 13px;
  color: var(--ink-3);
}

.chart {
  position: relative;
  min-width: 0;
  min-height: 196px;
}

/* Lebar SVG mengikuti wadah; tanpa max-width, lebar lama menahan grid saat layar menyempit. */
.chart svg {
  display: block;
  max-width: 100%;
  overflow: visible;
}

.chart svg:focus-visible {
  outline-offset: 6px;
}

.chart-bar {
  fill: var(--chart-bar);
  transition: fill 0.15s var(--ease);
}

.chart-bar.is-active {
  fill: var(--chart-bar-hover);
}

.chart-band {
  fill: var(--chart-band);
}

.chart-band-label {
  fill: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
}

.chart-grid {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.chart-tick {
  fill: var(--ink-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart-value {
  fill: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chart-hit {
  fill: transparent;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  display: grid;
  gap: 1px;
  padding: 7px 11px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--sheet);
  box-shadow: var(--shadow-rest);
  font-size: 12.5px;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 10px));
}

.chart-tooltip strong {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.chart-tooltip span {
  color: var(--ink-3);
}

.chart-table {
  margin-top: 8px;
  border-top: 1px solid var(--rule);
}

.chart-table summary {
  padding: 10px 0 2px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.chart-table table {
  margin-top: 8px;
}

.chart-table th {
  position: static;
}

.chart-table td {
  padding: 7px 14px;
}

.treatments {
  padding: 18px 20px 8px;
}

.treatments table {
  margin-top: 10px;
}

.treatments th {
  position: static;
}

.treatments tr:last-child td {
  border-bottom: 0;
}

/* ===== Pemberitahuan, dialog, toast, login ===== */

.notice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-radius: 14px;
  background: var(--amber);
  font-size: 13.5px;
}

.notice p {
  flex: 1;
  margin: 0;
}

.notice strong {
  font-weight: 600;
}

.notice-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber-dot);
}

.notice-aside {
  font-size: 12.5px;
  color: var(--amber-ink);
}

.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: var(--sheet);
  color: var(--ink);
  box-shadow: 0 30px 80px -24px rgba(12, 19, 34, 0.5);
}

.dialog::backdrop {
  background: rgba(12, 19, 34, 0.45);
}

.dialog-body {
  display: grid;
  gap: 16px;
  padding: 26px 26px 22px;
}

.dialog-title {
  margin: 0;
  font: 400 25px/1.15 var(--serif);
}

.steps {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 20px;
  color: var(--ink-2);
  font-size: 14px;
}

.qr-frame {
  display: grid;
  place-items: center;
  min-height: 272px;
  padding: 16px;
  border: 1px dashed var(--rule-3);
  border-radius: 18px;
}

.qr-frame img {
  width: 240px;
  height: 240px;
  image-rendering: pixelated;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
}

/* Hasil tindakan slip: catatan tetap di lembarnya, bukan toast yang menutupi isi. */
.slip-done {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--lilac);
  color: var(--lilac-ink);
  font-size: 13px;
  font-weight: 500;
}

.nowrap {
  white-space: nowrap;
}

.toasts {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 70;
  display: grid;
  justify-items: center;
  gap: 8px;
  translate: -50% 0;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lift);
  animation: rise 0.25s var(--ease) both;
}

.toast--alert {
  border: 1px solid rgba(163, 55, 43, 0.35);
  background: var(--sheet);
  color: var(--alert);
}

.login {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px 16px;
}

.login-sheet {
  display: grid;
  gap: 16px;
  width: min(430px, 100%);
  padding: 32px 30px 26px;
  box-shadow: var(--shadow-lift);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.login-title {
  margin: 6px 0 0;
  font: 400 33px/1.08 var(--serif);
  letter-spacing: -0.02em;
}

.login-lede {
  margin: -6px 0 4px;
  color: var(--ink-2);
  font-size: 14.5px;
}

.login-notice {
  margin: 0;
  padding: 10px 12px;
  border: 1px dashed var(--rule-3);
  border-radius: 12px;
  color: var(--ink-2);
  font-size: 13.5px;
}

.login-foot {
  margin: 4px 0 0;
  color: var(--ink-3);
  font-size: 13px;
}

.login-foot a {
  color: var(--ink-2);
  text-underline-offset: 3px;
  white-space: nowrap;
}

@keyframes rise {
  from {
    opacity: 0;
    translate: 0 6px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

@keyframes stamp-press {
  from {
    scale: 1.35;
    opacity: 0;
  }
  to {
    scale: 1;
    opacity: 0.92;
  }
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ===== Lebar layar ===== */

@media (max-width: 1279px) {
  .desk {
    grid-template-columns: 330px minmax(0, 1fr);
  }

  .detail-pane > .panel-scroll {
    background: var(--sheet);
  }
}

@media (max-width: 1099px) {
  .bookings {
    grid-template-columns: minmax(0, 1fr);
  }

  .charts,
  .report-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .report-grid > div:first-child > .report-row:last-child {
    border-bottom: 1px solid var(--rule);
  }
}

@media (max-width: 760px) {
  body {
    font-size: 15px;
  }

  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      'top'
      'stage'
      'nav';
  }

  .topbar {
    grid-area: top;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--rule);
    background: var(--paper);
  }

  .topbar-brand {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
  }

  .topbar-clinic {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar .wa-state {
    display: flex;
    align-items: center;
    max-width: none;
  }

  .topbar .menu {
    left: auto;
    right: 0;
    top: calc(100% + 8px);
    bottom: auto;
  }

  .rail {
    flex-direction: row;
    justify-content: center;
    gap: 0;
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--rule);
  }

  .rail-brand,
  .rail-foot {
    display: none;
  }

  .rail-nav {
    flex-direction: row;
    justify-content: space-around;
    width: 100%;
    gap: 2px;
  }

  .rail-nav li {
    flex: 1;
  }

  .rail-link {
    width: auto;
    padding: 8px 4px 6px;
  }

  .desk {
    grid-template-columns: minmax(0, 1fr);
  }

  .desk.has-selection .queue,
  .desk:not(.has-selection) .detail {
    display: none;
  }

  .queue {
    border-right: 0;
  }

  .column-head {
    padding: 16px 16px 10px;
  }

  .column-scroll {
    padding: 0 16px 24px;
  }

  .detail {
    padding: 8px;
  }

  .conv-head {
    padding: 10px 12px;
    gap: 10px;
  }

  .conv-actions .btn span {
    display: none;
  }

  .conv-actions .btn {
    padding: 8px 10px;
  }

  .thread {
    padding: 12px;
  }

  .bubble {
    max-width: 88%;
  }

  .composer {
    padding: 10px 12px 12px;
  }

  .composer-hint {
    display: none;
  }

  .composer-row .btn span {
    display: none;
  }

  .composer-row .btn {
    padding: 10px 14px;
  }

  .panel-scroll {
    padding: 16px 16px 28px;
  }

  .bookings-main {
    padding: 16px 16px 0;
  }

  .report {
    padding: 2px 18px;
  }

  .report-value {
    font-size: 26px;
  }

  .notice {
    flex-wrap: wrap;
  }

  .notice p {
    flex-basis: calc(100% - 24px);
  }

  .toasts {
    bottom: calc(84px + env(safe-area-inset-bottom));
    width: calc(100vw - 32px);
  }

  .toast {
    border-radius: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}
