/*
 * PayHero Admin — app layer on top of payhero-ui.css.
 * payhero-ui.css stays a verbatim copy of the design-system skill; app-specific
 * rules and Tailwind bridges live here.
 */

/* ===================================================================
   1. SHELL
   =================================================================== */
body.desk { font-family: var(--font); }
[x-cloak] { display: none !important; }

.desk-brand { color: inherit; text-decoration: none; }

/* Long nav: the sidebar column stays full height while its content sticks and scrolls. */
.desk-side-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.desk-nav { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.12) transparent; }
.desk-nav::-webkit-scrollbar { width: 4px; }
.desk-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 4px; }
.desk-nav .desk-nav-label:first-child { margin-top: 6px; }

.desk-menu > span { display: grid; place-items: center; line-height: 0; }
.desk-menu.is-open .desk-menu-close { display: grid; }

.desk-stage { position: relative; }
.desk-main { flex: 1; min-width: 0; }

@media (min-width: 1024px) {
  /* overflow: clip keeps the rounded frame without creating a scroll container, so sticky works */
  .desk-frame { overflow: clip; }
  .desk-side-inner {
    position: sticky;
    top: 0;
    height: calc(100vh - 16px);
  }
}

@media (max-width: 1023px) {
  .desk-side { overflow: hidden; }
  body.desk.is-locked { overflow: hidden; }
}

/* session chip in the top bar (not clickable) */
.desk-status.is-static { cursor: default; }
.desk-status-time { font-variant-numeric: tabular-nums; }
#session-chip { cursor: default; }
#session-chip.is-danger .desk-status-dot { background: var(--danger-bg); }
#session-chip.is-danger .desk-status-dot::after { background: var(--danger); }

/* user menu extras */
.desk-user-menu { z-index: 45; }
.desk-user-menu-note {
  margin: 0 0 4px;
  padding: 8px 12px 10px;
  border-bottom: 1px solid var(--divider);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.desk-user-menu .is-danger,
.desk-user-menu .is-danger svg { color: var(--danger-text); }
.desk-user-menu .is-danger:hover { background: var(--danger-bg); }

/* ===================================================================
   2. FEEDBACK: alerts, toasts, loader, install prompt
   =================================================================== */
.desk-alert p { margin: 0; }
.desk-alert .desk-alert-body { display: flex; align-items: flex-start; gap: 10px; }
.desk-alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.desk-alert .desk-btn { border: 1px solid var(--soft-line); background: #fff; color: #1e293b; }
.desk-alert .desk-btn.is-danger { border-color: var(--danger-line); background: #fff; color: var(--danger-text); }
.desk-alert .desk-btn.is-danger:hover { background: var(--danger-bg-hover); }
.desk-alert.is-success { border-color: #bfe9dc; background: #ecfaf5; color: var(--success-text); }
.desk-alert.is-success button { color: var(--success-text); }
.desk-alert.is-warning { border-color: #fde68a; background: #fffbeb; color: var(--warning-text); }
.desk-alert.is-warning button { color: var(--warning-text); }
.desk-alert.is-info { border-color: #bae6fd; background: #f0f9ff; color: var(--info-text); }
.desk-alert.is-info button { color: var(--info-text); }

.toastify.ph-toast {
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--navy);
  color: #fff;
  font: 600 13.5px/1.4 var(--font);
  box-shadow: var(--shadow-menu);
}
.toastify.ph-toast::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 10px;
  border-radius: 50%;
  vertical-align: 1px;
  background: var(--mint);
}
.toastify.ph-toast.is-success { background: var(--tone-green); }
.toastify.ph-toast.is-success::before { background: #fff; }
.toastify.ph-toast.is-error { background: var(--tone-rose); }
.toastify.ph-toast.is-error::before { background: #fff; }
.toastify.ph-toast.is-warning::before { background: var(--warning); }

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: rgba(238, 246, 243, 0.86);
  backdrop-filter: blur(6px);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.page-loader.hidden { display: grid !important; opacity: 0; visibility: hidden; pointer-events: none; }
.page-loader-card { display: grid; justify-items: center; gap: 16px; }
.page-loader .desk-logo { width: 52px; height: 52px; border-radius: 16px; box-shadow: var(--shadow-green); }
.page-loader .desk-logo img { width: 32px; height: 32px; }
.page-loader-spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid rgba(0, 170, 133, 0.18);
  border-top-color: var(--green);
  animation: ph-spin 0.7s linear infinite;
}
.page-loader-text { margin: 0; color: var(--muted); font-size: 12.5px; font-weight: 700; }
@keyframes ph-spin { to { transform: rotate(360deg); } }

.ph-install {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  width: min(360px, calc(100vw - 32px));
  box-shadow: var(--shadow-menu);
}
.ph-install .desk-card-head { align-items: flex-start; flex-wrap: nowrap; margin-bottom: 0; }
.ph-install-icon {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green-tint);
  color: var(--green-dark);
}
.ph-install-icon svg { width: 22px; height: 22px; }

@media (prefers-reduced-motion: reduce) {
  .page-loader-spinner { animation-duration: 1.6s; }
}

/* ===================================================================
   3. DATA TABLE (components/data-table.php)
   =================================================================== */
.ph-dt .desk-filters { align-items: stretch; }
.ph-dt .desk-filters .desk-select { min-height: 42px; }
.ph-dt-advanced { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.ph-dt-advanced .desk-select { width: auto; min-height: 40px; }
.ph-dt-advanced .desk-input { width: auto; min-width: 14rem; flex: 1 1 14rem; max-width: 24rem; min-height: 40px; }
.ph-dt-per-page { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 600; }
.ph-dt-per-page .desk-select { width: auto; }

.desk-table th.is-sortable { cursor: pointer; user-select: none; }
.desk-table th.is-sortable:hover { color: var(--text-2); }
.desk-table th.is-sorted { color: var(--green-dark); }
.ph-dt-sort { display: inline-flex; align-items: center; gap: 6px; }
.ph-dt-sort svg { width: 12px; height: 12px; opacity: 0.35; transition: transform 0.15s ease, opacity 0.15s ease; }
.is-sorted .ph-dt-sort svg { opacity: 1; }
.is-sorted.is-asc .ph-dt-sort svg { transform: rotate(180deg); }
.desk-table tbody tr.ph-row-alert { background: #fff7f8; }
.desk-table tbody tr.ph-row-alert:hover { background: #fff1f3; }
.desk-mobile-card.ph-row-alert { border-color: var(--danger-line); }
.ph-negative { color: var(--danger-text); }
.ph-positive { color: var(--success-text); }
.ph-seg-count.is-danger { background: var(--danger-bg-hover); color: var(--danger-text); }
.ph-dt .desk-table td { white-space: nowrap; }
.ph-dt .desk-table { min-width: 100%; }

.ph-dt-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px 16px; color: var(--muted); font-size: 14px; font-weight: 600; }
.ph-dt-loading::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(0, 170, 133, 0.2);
  border-top-color: var(--green);
  animation: ph-spin 0.7s linear infinite;
}
.ph-dt .desk-empty-dashed { margin: 16px; }
.ph-dt .desk-pager .desk-btn.is-current { border-color: var(--green); background: var(--green-tint); color: var(--green-dark); }

.ph-row-actions { display: inline-flex; gap: 6px; }
.ph-receipts { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.ph-muted-note { color: var(--faint); font-style: italic; }
.ph-cell-desc { max-width: 18rem; margin: 2px 0 0; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; }

/* ===================================================================
   3b. SHARED PAGE PIECES (filters, facts, panels, threads, pick lists)
   =================================================================== */
.desk-search.is-mono { font-family: var(--mono); font-size: 13px; }
.ph-filter-note { margin: -4px 0 12px; color: var(--muted); font-size: 12.5px; }
.desk-page-head p.ph-sync { margin-top: 4px; color: var(--green-dark); font-size: 12px; font-weight: 700; }
.ph-sync:empty { display: none; }
.ph-pager-page { padding: 0 6px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.ph-pager-page strong { color: var(--ink); }
.stat-card[data-dot="violet"] { --stat-dot: #6d28d9; }

.desk-link svg { display: inline-block; width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; }
.ph-fa { display: inline-flex; vertical-align: -0.125em; }
.ph-fa svg { display: block; width: 1em; height: 1em; }
.desk-btn svg + span { margin-left: 0; }

.ph-stack > * + * { margin-top: 16px; }
.ph-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ph-eyebrow { margin: 0; color: var(--subtle); font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }

.ph-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-input);
  background: var(--inset);
}
.ph-facts dt { color: var(--subtle); font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.ph-facts dd { margin: 4px 0 0; color: var(--ink); font-size: 14px; font-weight: 600; }
.ph-facts.is-compact { margin: 0; padding: 10px 12px; background: #fff; }
.ph-facts.is-compact dd { font-size: 13px; }
.ph-stack > .ph-facts { margin-bottom: 0; }

.ph-prose {
  color: var(--ink);
  font: 400 14px/1.6 var(--font);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ph-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--inset);
}
.ph-panel.is-green { border-color: var(--green-line); background: linear-gradient(180deg, #eefaf5 0%, #fbfefd 100%); }
.ph-panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.ph-panel-title { margin: 0; color: var(--ink-strong); font-size: 14px; font-weight: 800; letter-spacing: -0.01em; }
.ph-join { padding: 10px 12px; border: 1px solid var(--green-line); border-radius: var(--r-input); background: #fff; }
.ph-join a { display: block; margin-top: 4px; color: var(--green-dark); font-size: 14px; font-weight: 700; word-break: break-all; text-decoration: none; }
.ph-join a:hover { color: var(--green); text-decoration: underline; }

.ph-guest-list { max-height: 12rem; margin: 0; padding: 0; overflow-y: auto; list-style: none; border: 1px solid var(--line); border-radius: var(--r-input); background: #fff; }
.ph-guest-list:empty { display: none; }
.ph-guest { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 12px; border-top: 1px solid var(--divider); }
.ph-guest:first-child { border-top: 0; }
.ph-guest-email { min-width: 0; overflow: hidden; color: var(--ink); font-size: 13.5px; text-overflow: ellipsis; white-space: nowrap; }

.ph-check-result { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-input); font-size: 13px; font-weight: 600; }
.ph-check-result.is-ok { border-color: #bfe9dc; background: #ecfaf5; color: var(--success-text); }
.ph-check-result.is-busy { max-height: 8rem; overflow-y: auto; border-color: #fde68a; background: #fffbeb; color: var(--warning-text); }

.ph-btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  vertical-align: -2px;
  animation: ph-spin 0.7s linear infinite;
}

.ph-pick-list { display: grid; gap: 8px; max-height: min(40vh, 320px); overflow-y: auto; padding-right: 2px; }
.ph-pick {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-input);
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ph-pick:hover { border-color: var(--green-line); }
.ph-pick.is-on { border-color: var(--green); background: var(--green-tint); }
.ph-pick input { accent-color: var(--green); flex-shrink: 0; pointer-events: none; }
.ph-pick-copy { min-width: 0; flex: 1; }
.ph-pick-copy strong { display: block; overflow: hidden; color: var(--ink); font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.ph-pick-copy small { display: block; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.ph-image-preview { display: block; max-width: 18rem; height: 8rem; margin-top: 12px; object-fit: cover; border: 1px solid var(--line); border-radius: var(--r-input); }

/* ticket conversation */
.ph-ticket-dialog { max-width: 48rem; }
.ph-thread { display: grid; gap: 12px; max-height: 20rem; overflow-y: auto; padding: 4px 2px; }
.ph-msg { display: flex; align-items: flex-start; gap: 10px; }
.ph-msg.is-staff { flex-direction: row-reverse; }
.ph-msg-bubble { min-width: 0; max-width: 85%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; background: #fff; }
.ph-msg.is-staff .ph-msg-bubble { border-color: var(--green-line); border-radius: 16px 4px 16px 16px; background: var(--green-tint); }
.ph-msg-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 4px; }
.ph-msg-meta strong { color: var(--ink); font-size: 13px; font-weight: 700; }
.ph-msg-meta time { margin-left: auto; color: var(--subtle); font-size: 11.5px; font-weight: 600; }
.ph-reply { margin-top: 18px; padding: 16px; }
.ph-reply .desk-field + .desk-field, .ph-reply .desk-grid + .desk-field { margin-top: 14px; }

@media (max-width: 560px) {
  .ph-facts { grid-template-columns: 1fr; }
  .ph-msg-bubble { max-width: 100%; }
}

/* ===================================================================
   3c. MANAGE PAGES (files, logs, query runner, Power BI, connections)
   =================================================================== */
.dash-range input { border: 0; background: transparent; color: var(--ink); font: 700 13px/1 var(--font); outline: none; }
.desk-btn .desk-count { margin-left: 2px; }

.ph-overlay-loader {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(3px);
}

.ph-row-icon {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--inset);
  color: var(--muted);
}
.ph-row-icon svg { width: 22px; height: 22px; }
.ph-row-icon.is-on { background: var(--green-tint); color: var(--green-dark); }
.desk-row-title .desk-pill { margin-left: 8px; vertical-align: 1px; }

.ph-icon-danger:hover { border-color: var(--danger-line); color: var(--danger-text); background: var(--danger-bg); }

/* scrollable dialog: fixed head/foot, scrolling body */
.desk-dialog.is-xwide { max-width: 56rem; }
.desk-dialog.is-panel { display: flex; flex-direction: column; max-height: calc(100vh - 48px); margin: 0; padding: 0; overflow: hidden; }
.ph-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 12px; }
.ph-dialog-head h3 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.ph-dialog-bar { padding: 0 20px 14px; border-bottom: 1px solid var(--divider); }
.ph-dialog-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px; }
.ph-dialog-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--divider); background: var(--thead); }

.ph-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin-top: 6px; font-size: 13px; }
.ph-crumbs.is-page { margin: -10px 0 14px; }
.ph-crumbs button { padding: 2px 4px; border: 0; border-radius: 6px; background: none; color: var(--green-dark); font: 600 13px/1.3 var(--font); cursor: pointer; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-crumbs button:hover { color: var(--green); }
.ph-crumbs button.is-current { color: var(--ink); font-weight: 700; cursor: default; }
.ph-crumb { display: inline-flex; align-items: center; gap: 2px; }
.ph-crumb svg { width: 14px; height: 14px; color: var(--faint); }

.ph-dropzone {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 24px 16px;
  border: 1.5px dashed var(--soft-line);
  border-radius: 16px;
  background: var(--thead);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ph-dropzone strong { color: var(--text-2); font-size: 14px; font-weight: 600; }
.ph-dropzone.is-over { border-color: var(--green); background: var(--green-tint); }

.ph-progress-wrap { display: grid; gap: 6px; }
.ph-progress-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.ph-progress { height: 8px; overflow: hidden; border-radius: 999px; background: var(--track); }
.ph-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width 0.3s ease; }
.ph-progress.is-busy > span { animation: ph-pulse 1.2s ease-in-out infinite; }

.ph-bulkbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--green-line);
  border-radius: 16px;
  background: var(--green-tint);
}
.ph-bulkbar p { margin: 0; color: var(--text-2); font-size: 13.5px; }

/* file tiles (file manager + file picker) */
.ph-file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.ph-file-grid.is-page { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 16px; }
.ph-file {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 8px 8px 10px;
  border: 1px solid var(--card-line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.ph-file:hover { border-color: var(--green-line); box-shadow: 0 10px 24px rgba(0, 170, 133, 0.1); transform: translateY(-1px); }
.ph-file.is-selected { border-color: var(--green); box-shadow: var(--ring-focus), var(--shadow-card); }
.ph-file-thumb {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 12px;
  background: var(--inset);
  color: var(--faint);
}
.ph-file-thumb > svg { width: 44%; height: 44%; }
.ph-file.is-folder .ph-file-thumb { background: #fff8e6; color: #f5b301; }
.ph-file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ph-file-ext { padding: 4px 10px; border-radius: 999px; background: #fff; color: var(--text-3); font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; box-shadow: var(--shadow-input); }
.ph-file-check { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--green); color: #fff; }
.ph-file-check svg { width: 16px; height: 16px; }
.ph-file-box { position: absolute; top: 8px; left: 8px; z-index: 2; width: 18px; height: 18px; accent-color: var(--green); opacity: 0; transition: opacity 0.15s ease; }
.ph-file:hover .ph-file-box, .ph-file.is-selected .ph-file-box, .ph-file-box:focus-visible { opacity: 1; }
.ph-file-tools {
  position: absolute;
  right: 6px;
  bottom: 6px;
  left: 6px;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-input);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.ph-file:hover .ph-file-tools, .ph-file:focus-within .ph-file-tools { opacity: 1; transform: none; }
.ph-file-tools .dash-icon-btn { width: 28px; height: 28px; }
.ph-file-name { display: block; margin-top: 8px; padding: 0 2px; overflow: hidden; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.ph-file-meta { display: block; padding: 0 2px; color: var(--subtle); font-size: 11.5px; font-weight: 600; }
@media (hover: none) { .ph-file-tools, .ph-file-box { opacity: 1; transform: none; } }

.ph-ref-list { display: grid; gap: 8px; }
.ph-ref { display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-input); background: #fff; }
.ph-ref img { width: 56px; height: 56px; flex-shrink: 0; object-fit: cover; border-radius: 10px; }
.ph-qr-preview { width: 9rem; height: 9rem; flex-shrink: 0; object-fit: contain; border: 1px solid var(--line); border-radius: var(--r-input); background: #fff; }
.ph-preview-dialog { max-width: 52rem; }
.ph-preview { display: grid; place-items: center; max-height: 60vh; overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--inset); }
.ph-preview img { display: block; max-width: 100%; height: auto; }
.ph-preview iframe { width: 100%; height: 60vh; border: 0; }
.ph-preview video { display: block; width: 100%; }
.ph-preview audio { margin: 32px 16px; }

/* two-pane workspace (query runner, Power BI) */
.ph-workspace { display: flex; height: calc(100vh - 230px); min-height: 560px; }
.ph-ws-side { display: flex; flex-direction: column; width: 18rem; flex-shrink: 0; min-height: 0; border-right: 1px solid var(--divider); background: #fbfcfd; }
.ph-ws-side-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--divider); }
.ph-ws-side-head .desk-seg { display: flex; }
.ph-ws-side-head .desk-seg button { flex: 1; }
.ph-ws-side-body { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 10px; padding: 12px; }
.ph-ws-list { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.ph-ws-main { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }

.ph-tree { border-radius: 12px; }
.ph-tree + .ph-tree { margin-top: 2px; }
.ph-tree.is-open { background: #fff; box-shadow: inset 0 0 0 1px var(--line); }
.ph-tree-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: 12px; background: none; color: var(--ink); font: 600 13px/1.3 var(--font); text-align: left; cursor: pointer; }
.ph-tree-head:hover { background: var(--menu-hover); }
.ph-tree-head span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-tree-head svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--green); }
.ph-tree-head svg:last-child { color: var(--faint); transition: transform 0.15s ease; }
.ph-tree.is-open .ph-tree-head svg:last-child { transform: rotate(90deg); }
.ph-tree-body { padding: 4px 8px 10px; }
.ph-tree-samples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.ph-tree-samples .desk-btn { font-family: var(--mono); font-size: 11px; }
.ph-col { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 5px 6px; border: 0; border-radius: 8px; background: none; color: var(--text-2); font: 500 12.5px/1.3 var(--mono); text-align: left; cursor: copy; }
.ph-col:hover { background: var(--green-tint); color: var(--green-dark); }
.ph-col span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-col small { flex-shrink: 0; color: var(--subtle); font: 600 10.5px/1 var(--font); }

.ph-saved { position: relative; display: flex; align-items: flex-start; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.ph-saved + .ph-saved { margin-top: 8px; }
.ph-saved:hover { border-color: var(--green-line); }
.ph-saved.is-on { border-color: var(--green); background: var(--green-tint); }
.ph-saved-main { display: grid; gap: 4px; flex: 1; min-width: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.ph-saved-main strong { overflow: hidden; color: var(--ink); font-size: 13.5px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.ph-saved-main code { overflow: hidden; color: var(--muted); font: 12px/1.4 var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.ph-saved-main small { color: var(--subtle); font-size: 11.5px; font-weight: 600; }
.ph-saved-tools { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s ease; }
.ph-saved:hover .ph-saved-tools, .ph-saved:focus-within .ph-saved-tools { opacity: 1; }
.ph-saved-tools .dash-icon-btn { width: 28px; height: 28px; }
.ph-history { display: grid; gap: 8px; max-height: 26rem; margin-top: 12px; overflow-y: auto; }
.ph-history .ph-saved + .ph-saved { margin-top: 0; }

.ph-editor { display: flex; flex-direction: column; height: 36%; min-height: 200px; border-bottom: 1px solid var(--divider); }
.ph-editor-bar, .ph-results-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--divider); }
.ph-editor-body { position: relative; flex: 1; min-height: 0; }
.ph-results { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ph-results-bar { justify-content: space-between; }
.ph-results-body { position: relative; flex: 1; min-height: 0; padding: 14px 16px 16px; overflow: hidden; background: var(--canvas); }
.ph-results-table { height: 100%; overflow: auto; }
.ph-results-table thead th { position: sticky; top: 0; z-index: 1; background: var(--thead); }
.ph-results-json { height: 100%; overflow: auto; font-size: 12.5px; }
.ph-seg-count { margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--green-tint); color: var(--green-dark); font-size: 11px; font-weight: 800; }

.ph-popover { position: fixed; top: 96px; right: 40px; z-index: 45; width: min(26rem, calc(100vw - 32px)); box-shadow: var(--shadow-menu); }
.ph-code-inline { padding: 1px 6px; border-radius: 6px; background: var(--menu-hover); color: var(--green-dark); font: 600 12px/1.5 var(--mono); }
.ph-var-list { display: grid; gap: 6px; margin: 0; }
.ph-var-list > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 6px 10px; border-radius: 10px; background: #fff; font-size: 12.5px; }
.ph-var-list dt { color: var(--text-2); font-weight: 600; }
.ph-var-list dd { margin: 0; color: var(--muted); text-align: right; }

.ph-check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 6px; max-height: 11rem; margin-top: 10px; overflow-y: auto; }
.ph-check-grid.is-tall { max-height: 22rem; margin-top: 0; }
.ph-check { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.ph-check:hover { border-color: var(--green-line); }
.ph-check:has(input:checked) { border-color: var(--green); background: var(--green-tint); }
.ph-check input { accent-color: var(--green); flex-shrink: 0; }
.ph-check span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Power BI chat */
.ph-prompt { display: grid; gap: 3px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: inherit; font: inherit; text-align: left; cursor: pointer; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.ph-prompt + .ph-prompt { margin-top: 8px; }
.ph-prompt:hover { border-color: var(--green-line); box-shadow: 0 8px 20px rgba(0, 170, 133, 0.08); }
.ph-prompt strong { color: var(--ink); font-size: 13px; font-weight: 700; }
.ph-prompt small { color: var(--muted); font-size: 11.5px; }
.ph-chat { flex: 1; min-height: 0; overflow-y: auto; padding: 22px; }
.ph-chat-welcome { display: grid; justify-items: center; gap: 10px; max-width: 30rem; margin: 6vh auto 0; text-align: center; }
.ph-chat-welcome .dash-hero-icon { background: var(--green-tint); box-shadow: none; }
.ph-chat-welcome h3 { margin: 4px 0 0; color: var(--ink-strong); font-size: 1.4rem; font-weight: 800; letter-spacing: -0.03em; }
.ph-chat-welcome > p { margin: 0 0 8px; color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.ph-chat-welcome .ph-panel { width: 100%; }
.ph-chat-turn + .ph-chat-turn { margin-top: 16px; }
.ph-chat-user { display: flex; justify-content: flex-end; }
.ph-chat-user p { max-width: min(36rem, 85%); margin: 0; padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: var(--green); color: #fff; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-btn); }
.ph-ai-bubble { flex: 1; max-width: min(52rem, 100%); }
.ph-ai-bubble .ph-prose { white-space: normal; }
.ph-chart-box { position: relative; height: 22rem; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.ph-sql-reveal { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--divider); }
.ph-sql { position: relative; width: 100%; }
.ph-sql .desk-btn { position: absolute; top: 8px; right: 8px; }
.ph-composer { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 8px; padding: 14px 16px 12px; border-top: 1px solid var(--divider); background: #fff; }
.ph-composer .desk-textarea { min-height: 46px; max-height: 150px; resize: none; }
.ph-composer .desk-btn { min-height: 46px; }
.ph-composer .desk-help { grid-column: 1 / -1; margin: 0; }

/* money pages */
.ph-split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.ph-result-tile { min-height: 228px; }
.desk-input.is-date {
  padding-right: 38px;
  cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='1.8' stroke-linecap='round'%3E%3Crect x='4' y='5' width='16' height='15' rx='2'/%3E%3Cpath d='M8 3v4M16 3v4M4 10h16'/%3E%3C/svg%3E") no-repeat right 12px center / 16px;
}
.desk-input.is-sm { padding: 7px 10px; font-size: 13.5px; }
.ph-total-row td { background: var(--thead); font-weight: 800; border-top: 2px solid var(--line); }
.ph-total-row:hover td { background: var(--thead); }

.ph-builder { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; gap: 18px; align-items: start; }
.ph-builder-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; min-width: 0; }
.ph-builder-side { position: sticky; top: 16px; }
.ph-form-grid { display: grid; gap: 14px; }
.ph-form-grid.is-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ph-form-grid.is-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ph-form-grid .desk-field + .desk-field { margin-top: 0; }
.ph-items td { vertical-align: middle; }
.ph-items .desk-input { min-width: 6rem; }
.ph-recipient { display: flex; align-items: flex-start; gap: 14px; padding: 16px; border: 1px solid var(--green-line); border-radius: 16px; background: linear-gradient(180deg, #eefaf5 0%, #fbfefd 100%); }
.ph-recipient-name { margin: 2px 0 0; color: var(--ink-strong); font-size: 17px; font-weight: 800; letter-spacing: -0.02em; }
.ph-pick .dash-avatar { flex-shrink: 0; }
button.ph-pick { width: 100%; font: inherit; text-align: left; }
.ph-logo-preview { display: grid; place-items: center; min-height: 6rem; margin-top: 12px; padding: 12px; border: 1px dashed var(--soft-line); border-radius: var(--r-input); background: var(--thead); }
.ph-logo-preview img { max-width: 100%; max-height: 5rem; object-fit: contain; }

.ph-summary-total { margin: 6px 0 14px; color: var(--ink-strong); font-size: 2rem; font-weight: 800; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.ph-summary-lines { display: grid; margin: 0; border-top: 1px solid var(--divider); }
.ph-summary-lines > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; border-bottom: 1px solid var(--divider); font-size: 13.5px; }
.ph-summary-lines dt { color: var(--muted); font-weight: 600; }
.ph-summary-lines dd { margin: 0; color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.ph-summary-balance.is-due dt, .ph-summary-balance.is-due dd { color: var(--danger-text); }
.ph-summary-balance.is-paid dt, .ph-summary-balance.is-paid dd { color: var(--success-text); }
.ph-inline-check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.ph-inline-check input { accent-color: var(--green); }
.ph-rate { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; }
.ph-rate .desk-input { width: 5rem; text-align: right; }
.ph-summary-actions { display: grid; gap: 8px; margin-top: 18px; }

.flatpickr-calendar { border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-menu); font-family: var(--font); }
.flatpickr-day.selected, .flatpickr-day.selected:hover, .flatpickr-day.startRange, .flatpickr-day.endRange { border-color: var(--green); background: var(--green); }
.flatpickr-day.today { border-color: var(--green-line); }
.flatpickr-day:hover { background: var(--green-tint); border-color: var(--green-tint); }
.flatpickr-months .flatpickr-month, .flatpickr-current-month { font-weight: 800; }

/* ---------- detail + form pages ---------- */
.ph-crumbs.is-head { margin: 0 0 6px; color: var(--muted); font-weight: 600; }
.ph-crumbs a { color: var(--green-dark); text-decoration: none; }
.ph-crumbs a:hover { text-decoration: underline; }
.ph-crumbs > span { padding: 0 4px; }
.ph-ellipsis { max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desk-select.is-danger { border-color: var(--danger-line); background-color: var(--danger-bg); color: var(--danger-text); font-weight: 700; }

.ph-profile-photo, .ph-profile-avatar { flex-shrink: 0; width: 64px; height: 64px; border-radius: 999px; }
.ph-profile-photo { object-fit: cover; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--green-line); }
.ph-profile-avatar { font-size: 20px; }

.ph-verdict { display: flex; align-items: flex-start; gap: 14px; padding: 16px; border: 1px solid; border-radius: 16px; }
.ph-verdict.is-ok { border-color: #bfe9dc; background: #ecfaf5; color: var(--success-text); }
.ph-verdict.is-fail { border-color: var(--danger-line); background: var(--danger-bg); color: var(--danger-text); }
.ph-verdict-icon svg { width: 32px; height: 32px; }
.ph-verdict-title { margin: 2px 0 0; font-size: 17px; font-weight: 800; letter-spacing: -0.02em; }
.ph-verdict-copy { margin: 4px 0 0; font-size: 13.5px; font-weight: 500; opacity: 0.9; }
.ph-raw { margin-top: 16px; }
.ph-raw summary { color: var(--green-dark); font-size: 13px; font-weight: 700; cursor: pointer; }
.ph-raw pre { max-height: 22rem; margin: 10px 0 0; padding: 12px 14px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--thead); color: var(--text-2); font: 12px/1.55 var(--mono); }
.ph-steps-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: ph-step; }
.ph-steps-list li { position: relative; padding-left: 36px; color: var(--muted); font-size: 13.5px; line-height: 1.5; counter-increment: ph-step; }
.ph-steps-list li::before { content: counter(ph-step); position: absolute; top: 0; left: 0; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 999px; background: var(--green-tint); color: var(--green-dark); font-size: 12px; font-weight: 800; }
.ph-steps-list strong { color: var(--ink); }

.ph-doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 10px; }
.ph-doc { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; font: inherit; text-align: left; cursor: pointer; }
.ph-doc:hover { border-color: var(--green); background: var(--green-tint); }
.ph-doc .ph-row-icon { width: 38px; height: 38px; border-radius: 12px; }
.ph-doc .ph-row-icon svg { width: 19px; height: 19px; }
.ph-doc strong { display: block; color: var(--ink); font-size: 13.5px; font-weight: 700; }
.ph-doc small { display: block; color: var(--muted); font-size: 12px; }
.ph-doc-view { display: grid; place-items: center; min-height: 20rem; background: var(--thead); }
.ph-doc-view img { display: block; max-width: 100%; max-height: 72vh; object-fit: contain; }
.ph-doc-view iframe { width: 100%; height: 72vh; border: 0; }
.ph-review { display: grid; grid-template-columns: minmax(0, 1fr) 18rem; gap: 18px; align-items: start; }

.ph-actions .ph-sync { color: var(--green-dark); font-size: 12px; font-weight: 700; }
.ph-inbox { display: flex; flex-direction: column; height: calc(100vh - 220px); min-height: 32rem; overflow: hidden; }
.ph-inbox-pane { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.ph-inbox-bar { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--divider); }
.ph-inbox-bar .desk-search { flex: 1; max-width: 32rem; }
.ph-inbox-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.ph-mail-list { margin: 0; padding: 0; list-style: none; }
.ph-mail-list li + li { border-top: 1px solid var(--divider); }
.ph-mail-row { display: grid; grid-template-columns: 32px 12rem minmax(0, 1fr) auto; align-items: center; gap: 14px; width: 100%; padding: 12px 18px; border: 0; background: #fff; color: var(--text-2); font: inherit; text-align: left; cursor: pointer; }
.ph-mail-row:hover { background: var(--menu-hover); }
.ph-mail-row.is-unread { background: #f3fbf8; }
.ph-mail-row.is-unread .ph-mail-from, .ph-mail-row.is-unread .ph-mail-subject strong, .ph-mail-row.is-unread .ph-mail-date { color: var(--ink-strong); font-weight: 800; }
.ph-mail-avatar { display: grid; place-items: center; width: 32px; height: 32px; }
.ph-mail-avatar img { width: 32px; height: 32px; border-radius: 999px; background: var(--inset); }
.ph-mail-from { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--ink); font-size: 13.5px; font-weight: 600; }
.ph-mail-from > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-mail-subject { min-width: 0; overflow: hidden; font-size: 13.5px; text-overflow: ellipsis; white-space: nowrap; }
.ph-mail-subject strong { color: var(--ink); font-weight: 600; }
.ph-mail-subject span { margin-left: 8px; color: var(--muted); }
.ph-mail-date { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ph-thread-subject { min-width: 0; margin: 0; overflow: hidden; color: var(--ink-strong); font-size: 17px; font-weight: 800; letter-spacing: -0.02em; text-overflow: ellipsis; white-space: nowrap; }
.ph-thread-msgs { display: grid; align-content: start; gap: 12px; padding: 16px 18px; background: var(--thead); }
.ph-mail-msg { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.ph-mail-msg-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; border: 0; background: #fff; font: inherit; text-align: left; cursor: pointer; }
.ph-mail-msg-head:hover { background: var(--menu-hover); }
.ph-mail-msg-head strong { display: block; overflow: hidden; color: var(--ink); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.ph-mail-msg-head small { color: var(--muted); font-size: 12px; }
.ph-mail-msg-body { padding: 4px 20px 18px; border-top: 1px solid var(--divider); }
.ph-mail-html { padding-top: 14px; overflow-x: auto; color: var(--ink); font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.ph-mail-html img { max-width: 100%; height: auto; }
.ph-mail-html p, .ph-mail-html ul, .ph-mail-html ol, .ph-mail-html blockquote { margin: 0 0 10px; }
.ph-mail-html ul { padding-left: 20px; list-style: disc; }
.ph-mail-html ol { padding-left: 20px; list-style: decimal; }
.ph-mail-html blockquote { padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.ph-mail-html a { color: var(--green-dark); text-decoration: underline; }
.ph-quill { overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-input); background: #fff; }
.ph-quill .ql-toolbar.ql-snow { border: 0; border-bottom: 1px solid var(--divider); background: var(--thead); font-family: var(--font); }
.ph-quill .ql-container.ql-snow { height: 16rem; border: 0; font: 14px/1.6 var(--font); }

@media (max-width: 900px) {
  .ph-review { grid-template-columns: 1fr; }
  .ph-mail-row { grid-template-columns: 32px minmax(0, 1fr) auto; }
  .ph-mail-subject { grid-column: 2 / -1; grid-row: 2; }
  .ph-mail-row .ph-mail-avatar { grid-row: span 2; align-self: start; }
}

/* ---------- campaigns (email + sms) ---------- */
.ph-form-grid.is-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ph-loaded { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-top: 14px; padding: 12px 14px; border: 1px solid var(--green-line); border-radius: 14px; background: var(--green-tint); }
.ph-loaded p { margin: 0; color: var(--green-dark); font-size: 13.5px; }
.ph-char-count { color: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ph-char-count.is-over { color: var(--warning-text); }
.ph-summary-of { margin-left: 4px; color: var(--muted); font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }
.ph-tip { margin: 12px 0 0; padding: 10px 12px; border: 1px solid #fde7b0; border-radius: 12px; background: #fffaeb; color: #8a5a00; font-size: 12.5px; line-height: 1.5; }
.ph-send-progress { margin-top: 16px; padding: 14px; border: 1px solid var(--green-line); border-radius: 14px; background: var(--green-tint); }

.ph-steps { display: flex; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ph-steps > li { flex: 1; min-width: 0; }
.ph-step { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; color: var(--muted); font: inherit; text-align: left; cursor: pointer; }
.ph-step:disabled { cursor: not-allowed; opacity: 0.6; }
.ph-step-num { display: grid; place-items: center; flex-shrink: 0; width: 28px; height: 28px; border: 1.5px solid var(--soft-line); border-radius: 999px; background: #fff; font-size: 12.5px; font-weight: 800; }
.ph-step-copy { min-width: 0; }
.ph-step-copy strong { display: block; color: var(--ink); font-size: 13.5px; font-weight: 700; }
.ph-step-copy small { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.ph-step.is-current { border-color: var(--green); background: var(--green-tint); }
.ph-step.is-current .ph-step-num { border-color: var(--green); background: var(--green); color: #fff; }
.ph-step.is-done .ph-step-num { border-color: var(--green-line); background: var(--green-tint); color: var(--green-dark); }

.ph-source-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ph-source { display: flex; align-items: flex-start; gap: 12px; padding: 16px; border: 1.5px solid var(--line); border-radius: 16px; background: #fff; font: inherit; text-align: left; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.ph-source:hover { border-color: var(--green-line); }
.ph-source.is-on { border-color: var(--green); background: var(--green-tint); }
.ph-source strong { display: block; color: var(--ink-strong); font-size: 14.5px; font-weight: 800; }
.ph-source small { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; line-height: 1.45; }

.ph-var-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ph-var-chip { display: inline-flex; flex-direction: column; align-items: flex-start; max-width: 14rem; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font: inherit; text-align: left; cursor: pointer; }
.ph-var-chip:hover { border-color: var(--green); background: var(--green-tint); }
.ph-var-chip code { color: var(--green-dark); font: 600 12px/1.4 var(--mono); }
.ph-var-chip small { max-width: 100%; overflow: hidden; color: var(--muted); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.ph-var-chip.is-shared code { color: #0369a1; }

.ph-mail-frame { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.ph-mail-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--divider); background: var(--thead); color: var(--muted); font-size: 12.5px; font-weight: 600; }
.ph-mail-bar small { display: block; color: var(--subtle); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.ph-mail-bar strong { display: block; overflow: hidden; color: var(--ink); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.ph-mail-body { max-height: 600px; padding: 24px; overflow-y: auto; }
.ph-mail-body.is-editable { min-height: 420px; outline: 0; }
.ph-mail-body.is-editable:focus { box-shadow: inset 0 0 0 2px var(--green-line); }
.ph-mail-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--divider); background: var(--thead); color: var(--muted); font-size: 12.5px; }
.ph-mail-code { display: block; width: 100%; min-height: 26rem; padding: 14px 16px; border: 0; outline: 0; background: #fbfcfd; color: var(--ink); font: 13px/1.6 var(--mono); resize: vertical; tab-size: 2; }
#email-code-editor-container.ring-2 { box-shadow: inset 0 0 0 2px var(--green-line); }

.ph-toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--divider); background: #fff; }
.ph-tool-group { display: inline-flex; align-items: center; gap: 2px; padding-right: 6px; border-right: 1px solid var(--divider); }
.ph-tool-group:last-child { border-right: 0; }
.ph-tool { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); font: 600 14px/1 var(--font); cursor: pointer; }
.ph-tool:hover { background: var(--menu-hover); color: var(--ink-strong); }
.ph-tool svg { width: 17px; height: 17px; }
.ph-tool.is-text { color: var(--green-dark); font-family: var(--mono); font-size: 12.5px; }
.ph-tool-select { height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text-2); font: 600 12.5px var(--font); }

.ph-kv-list { display: grid; gap: 8px; }
.ph-kv-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; align-items: center; gap: 8px; }

.ph-inspiration { display: flex; align-items: flex-start; gap: 12px; margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--thead); }
.ph-inspiration img { flex-shrink: 0; width: 4.5rem; height: 6rem; border-radius: 8px; object-fit: cover; background: #fff; }
.ph-inspiration strong { display: block; color: var(--ink); font-size: 13.5px; }
.ph-inspiration small { display: block; margin-bottom: 4px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.ph-swatches { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.ph-swatch { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.ph-swatch > input[type=color] { flex-shrink: 0; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; }
.ph-swatch > span { min-width: 0; flex: 1; }
.ph-swatch small { display: block; margin-bottom: 2px; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.ph-range { width: 100%; accent-color: var(--green); }

@media (max-width: 767px) {
  .ph-form-grid.is-2, .ph-source-grid { grid-template-columns: 1fr; }
  .ph-step-copy small { display: none; }
  .ph-mail-body { padding: 12px; }
  .ph-swatches { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ph-kv-row { grid-template-columns: 1fr auto; }
  .ph-kv-row > button { grid-row: 1; grid-column: 2; }
  .ph-kv-row > .desk-input:nth-child(2) { grid-column: 1 / -1; }
}

@media (max-width: 1280px) {
  .ph-builder { grid-template-columns: minmax(0, 1fr) 19rem; }
  .ph-form-grid.is-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .ph-builder { grid-template-columns: minmax(0, 1fr); }
  .ph-builder-side { position: static; }
  .ph-split { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  .ph-form-grid.is-3, .ph-form-grid.is-4 { grid-template-columns: 1fr; }
}

@media (max-width: 1023px) {
  .ph-workspace { flex-direction: column; height: auto; min-height: 0; }
  .ph-ws-side { width: auto; max-height: 18rem; border-right: 0; border-bottom: 1px solid var(--divider); }
  .ph-editor { height: 16rem; }
  .ph-results { min-height: 24rem; }
  .ph-chat { min-height: 26rem; }
  .ph-popover { top: auto; right: 16px; bottom: 16px; }
}

/* ===================================================================
   4. TAILWIND BRIDGE — legacy page markup picks up PayHero surfaces
   =================================================================== */
.desk-main { color: var(--ink); }
.desk-main h1.text-2xl, .desk-main h1.text-3xl, .desk-main h2.text-2xl, .desk-main h2.text-3xl { font-weight: 800; letter-spacing: -0.04em; }
.desk-main h3.text-lg, .desk-main h2.text-lg, .desk-main h2.text-xl, .desk-main h3.text-xl { font-weight: 800; letter-spacing: -0.02em; }

/* white cards */
.desk-main .bg-white.shadow,
.desk-main .bg-white.shadow-sm,
.desk-main .bg-white.shadow-md,
.desk-main .bg-white.rounded-lg.border,
.desk-main .bg-white.rounded-xl.border {
  border: 1px solid var(--card-line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}

/* form controls */
.desk-main input[type="text"]:not(.desk-input),
.desk-main input[type="email"]:not(.desk-input),
.desk-main input[type="number"]:not(.desk-input),
.desk-main input[type="search"]:not(.desk-input),
.desk-main input[type="date"]:not(.desk-input),
.desk-main input[type="datetime-local"]:not(.desk-input),
.desk-main input[type="tel"]:not(.desk-input),
.desk-main input[type="password"]:not(.desk-input),
.desk-main select:not(.desk-select),
.desk-main textarea:not(.desk-textarea) {
  border-color: var(--input-line);
  color: var(--ink);
}
.desk-main input:not([type="checkbox"]):not([type="radio"]):focus,
.desk-main select:focus,
.desk-main textarea:focus {
  outline: none;
  border-color: var(--green);
  --tw-ring-color: rgba(0, 170, 133, 0.12);
  box-shadow: var(--ring-focus);
}
.desk-main input[type="checkbox"], .desk-main input[type="radio"] { accent-color: var(--green); }

/* legacy table headers */
.desk-main table thead th { color: var(--subtle); font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; }

/* every focusable control shows the green ring */
.desk-main a:focus-visible,
.desk-main button:focus-visible,
.desk-btn:focus-visible,
.nav-item:focus-visible,
.desk-user summary:focus-visible,
.desk-menu:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(0, 170, 133, 0.28);
}

/* ===================================================================
   5. STAT CARDS + DASHBOARD EXTRAS
   =================================================================== */
.stat-card.is-static { cursor: default; }
.stat-plain.is-static:hover { transform: none; border-color: var(--card-line); box-shadow: var(--shadow-card); }
.stat-value .ph-skeleton {
  display: inline-block;
  width: 4.5rem;
  height: 1.6rem;
  border-radius: 8px;
  background: var(--track);
  animation: ph-pulse 1.2s ease-in-out infinite;
}
.stat-green .stat-value .ph-skeleton { background: rgba(255, 255, 255, 0.22); }
@keyframes ph-pulse { 50% { opacity: 0.5; } }
@media (min-width: 1024px) {
  .stat-grid.is-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ===================================================================
   5b. DASHBOARD EXTRAS
   =================================================================== */
a.dash-quick-card, a.dash-more, a.dash-btn { text-decoration: none; }
.dash-section ~ .dash-section { margin-top: 40px; }
.dash-hero-stat { flex-wrap: wrap; row-gap: 6px; }
/* Values still loading from the API show a shimmering bar in place of the number */
.dash-hero-num.is-loading,
.dash-hero-foot strong.is-loading,
.dash-guest-stats strong.is-loading,
.dash-minis strong.is-loading {
  color: transparent !important;
  border-radius: 8px;
  background: linear-gradient(90deg, #e1e8ef 0%, #f3f6f9 50%, #e1e8ef 100%) 0 0 / 200% 100%;
  animation: ph-shimmer 1.3s ease-in-out infinite;
  user-select: none;
}
.dash-hero-num.is-loading { min-width: 2.4em; }
.dash-hero-foot strong.is-loading,
.dash-guest-stats strong.is-loading,
.dash-minis strong.is-loading { width: 6.5em; max-width: 100%; }
.dash-hero-card .dash-hero-num.is-loading,
.dash-hero-card .dash-hero-foot strong.is-loading {
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0.34) 50%, rgba(255, 255, 255, 0.14) 100%);
}
.dash-chart.is-loading canvas { opacity: 0.2; transition: opacity 0.2s ease; }
.dash-chart.is-loading::before {
  content: "";
  position: absolute;
  top: calc(50% - 24px);
  left: calc(50% - 13px);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid rgba(0, 170, 133, 0.18);
  border-top-color: var(--green);
  animation: ph-spin 0.7s linear infinite;
}
.dash-chart.is-loading::after {
  content: "Loading chart…";
  position: absolute;
  top: calc(50% + 12px);
  left: 0;
  right: 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  text-align: center;
}
@keyframes ph-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) {
  .dash-hero-num.is-loading,
  .dash-hero-foot strong.is-loading,
  .dash-guest-stats strong.is-loading,
  .dash-minis strong.is-loading { animation: ph-pulse 1.6s ease-in-out infinite; }
  .dash-chart.is-loading::before { animation-duration: 1.6s; }
}
.dash-balances { display: flex; flex-direction: column; }
.dash-balances .dash-guest-stats { flex: 1; align-content: start; }
.dash-balances .dash-guest-stats strong { font-variant-numeric: tabular-nums; }
.dash-balances .dash-guest-stats .is-muted { color: var(--faint); font-size: 14px; font-weight: 600; }
.dash-balance-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.dash-balance-actions svg { width: 14px; height: 14px; }
.dash-hero-num .fa-spinner { font-size: 1.4rem; }
.dash-balance-grid { margin-top: 18px; }
.dash-balance-grid .stat-card { cursor: default; }
.dash-balance-grid .stat-plain:hover { transform: none; }
.dash-balance-grid .stat-note a,
.dash-balance-grid .stat-note button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--green-dark);
  font: 700 12px/1.2 var(--font);
  text-decoration: none;
  cursor: pointer;
}
.dash-balance-grid .stat-note a:hover,
.dash-balance-grid .stat-note button:hover { color: var(--green); }
.stat-green .stat-note a { color: #fff; }

/* ===================================================================
   6. LOGIN EXTRAS (verification-code step)
   =================================================================== */
.login-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 18px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 600;
}
.login-notice svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.login-notice.is-info { border: 1px solid var(--green-line); background: var(--green-tint); color: var(--text-2); }
.login-notice.is-info strong { color: var(--green-dark); }
.login-notice.is-success { border: 1px solid #bfe9dc; background: #ecfaf5; color: var(--success-text); }
.login-error-sub { display: block; margin-top: 2px; font-size: 12.5px; font-weight: 500; opacity: 0.85; }
.login-input input.login-otp {
  padding-right: 16px;
  font: 700 22px/1 var(--mono);
  letter-spacing: 0.5em;
  text-align: center;
}
.login-input input.login-otp::placeholder { letter-spacing: 0.5em; }
.login-resend { margin: 14px 0 0; text-align: center; }
.login-link-btn {
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--green-dark);
  font: 700 13px/1.2 var(--font);
  cursor: pointer;
}
.login-link-btn:hover { color: var(--green); text-decoration: underline; }
.login-link-btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }

/* ===================================================================
   7. 404
   =================================================================== */
.ph-404 { max-width: 30rem; margin: 8vh auto 0; text-align: center; }
.ph-404-code {
  margin: 0;
  font-size: 5rem;
  font-weight: 800;
  letter-spacing: -0.06em;
  line-height: 1;
  color: var(--green);
}
.ph-404 h2 { margin: 12px 0 0; font-size: 1.85rem; font-weight: 800; letter-spacing: -0.04em; }
.ph-404 p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.ph-404 .desk-page-actions { justify-content: center; margin-top: 22px; }
