/* ============================================================
   Unit Detail — styles lifted from
   _design/zain-os/project/Unit Detail - A.html.
   ============================================================ */

.ud-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 14px;
  padding: 4px 8px 4px 0;
  border-radius: 4px;
  transition: color var(--dur-default) var(--ease);
}
.ud-back:hover { color: var(--brand); }
.ud-back svg { width: 12px; height: 12px; }

.ud-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.ud-title-group { min-width: 0; flex: 1; }
.ud-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.ud-title {
  font-size: var(--fs-22);
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.2;
}
.ud-meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: var(--fs-13);
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.ud-meta-row .sep { color: var(--text-tertiary); }
.ud-meta-row .mono { font-family: var(--font-mono); }
.ud-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ud-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.ud-status-badge .d { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ud-status-badge.available { background: var(--brand-soft); color: var(--brand); }
.ud-status-badge.reserved  { background: rgba(212, 165, 116, 0.14); color: #d4a574; }
.ud-status-badge.sold      { background: rgba(120, 120, 120, 0.14); color: var(--text-secondary); }

.ud-delivery-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--brand-subtle);
  border: 1px solid var(--brand-dim);
  border-radius: var(--r-sm);
  font-size: var(--fs-11);
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}
.ud-delivery-chip svg { width: 10px; height: 10px; }

.ud-btn {
  height: var(--btn-md);
  min-width: var(--btn-w-md);
  padding: 0 14px;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
.ud-btn:hover { border-color: var(--brand-dim); color: var(--brand); }
.ud-btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}
.ud-btn.primary:hover { background: var(--brand-hover); color: #fff; }
.ud-btn svg { width: 14px; height: 14px; }

.ud-subtabs {
  display: flex;
  gap: var(--sp-1);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 24px;
  overflow-x: auto;
}
.ud-subtab {
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--dur-default) var(--ease), border-color var(--dur-default) var(--ease);
  cursor: pointer;
  background: transparent;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  font-family: inherit;
  white-space: nowrap;
}
.ud-subtab:hover { color: var(--text); }
.ud-subtab.is-active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}
.ud-subtab .subtab-count {
  margin-left: 6px;
  padding: 1px 7px;
  font-size: var(--fs-10);
  background: var(--hover);
  border-radius: var(--r-pill);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.ud-subtab.is-active .subtab-count { background: var(--brand-soft); color: var(--brand); }

.ud-tab-panel { display: none; }
.ud-tab-panel.is-active { display: block; }

/* ---------- Hero: photo + price card ---------- */
.unit-hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}
.hero-photo {
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(180deg, rgba(0,0,0,0) 60%, rgba(0,0,0,0.45) 100%),
    repeating-linear-gradient(135deg, #2a2725 0, #2a2725 10px, #252220 10px, #252220 20px);
  border-radius: var(--r-md);
  border: 1px solid var(--border-light);
  position: relative;
  overflow: hidden;
}
.hero-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-photo .photo-label {
  position: absolute;
  bottom: 14px; left: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  background: rgba(0, 0, 0, 0.4);
  padding: 3px 8px;
  border-radius: 4px;
}
.hero-photo .photo-count {
  position: absolute;
  top: 14px; right: 14px;
  font-size: 11px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.55);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  backdrop-filter: blur(4px);
}

.price-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
}
.price-card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.price-card-header .t-h3 { font-size: var(--fs-16); font-weight: var(--fw-semibold); }
.price-card-header .t-caption { font-size: var(--fs-12); color: var(--text-secondary); font-family: var(--font-mono); }

.price-row {
  display: grid;
  grid-template-columns: 1fr auto;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-light);
  align-items: center;
  gap: 12px;
}
.price-row:last-child { border-bottom: 0; }
.price-row .k {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.price-row .k svg { width: 12px; height: 12px; opacity: 0.7; }
.price-row .v {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.005em;
  white-space: nowrap;
}
.price-row.total {
  background: var(--brand-subtle);
  border-top: 1px solid var(--brand-dim);
  border-bottom: 1px solid var(--brand-dim);
}
.price-row.total .k {
  color: var(--brand);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
}
.price-row.total .v { color: var(--brand); font-size: 22px; }

.profit-tag {
  font-size: 10px;
  color: var(--text-tertiary);
  background: var(--hover);
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 4px;
}

.profit-edit-trigger {
  width: 22px; height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--text-tertiary);
  background: transparent;
  border: 0;
  cursor: pointer;
  margin-left: 6px;
  transition: color var(--dur-default) var(--ease), background var(--dur-default) var(--ease);
}
.profit-edit-trigger:hover { color: var(--brand); background: var(--brand-soft); }
.profit-edit-trigger svg { width: 12px; height: 12px; }

.breakdown-bar {
  height: 6px;
  background: var(--hover);
  border-radius: var(--r-pill);
  overflow: hidden;
  display: flex;
  margin: 12px 20px 16px;
}
.breakdown-bar .seg-paid { background: var(--brand); }
.breakdown-bar .seg-remaining { background: var(--brand-dim); opacity: 0.5; }

/* ---------- Meta grid ---------- */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border-light);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: 24px;
}
.meta-cell {
  background: var(--card);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.meta-cell .mk {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}
.meta-cell .mv {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meta-cell .mv.sub-caption { font-size: 11px; color: var(--text-tertiary); font-weight: 500; margin-top: 2px; white-space: normal; }

/* ---------- Two-col (upcoming installments + side stack) ---------- */
.ud-two-col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-top: 0;
}
.ud-col { display: flex; flex-direction: column; gap: 16px; }

.ud-card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  overflow: hidden;
}
.ud-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  gap: 10px;
}
.ud-card-title { font-size: var(--fs-15); font-weight: var(--fw-semibold); }
.ud-card-title-meta { font-size: 12px; color: var(--text-secondary); font-weight: 400; margin-left: 8px; }
.ud-card-body { padding: 16px 20px; }
.ud-card-body.flush { padding: 0; }

.timeline { display: flex; flex-direction: column; }
.timeline-item {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-light);
  align-items: center;
}
.timeline-item:last-child { border-bottom: 0; }
.timeline-item .date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}
.timeline-item .title { font-size: 13px; }
.timeline-item .muted { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.timeline-item .amount {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.client-mini {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
}
.client-mini:last-child { border-bottom: 0; }
.client-mini .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--hover);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.client-mini .info { flex: 1; min-width: 0; }
.client-mini .name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.client-mini .sub { font-size: 11px; color: var(--text-secondary); }
.client-mini .score-badge {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.action-grid .ud-btn { width: 100%; }

/* ---------- Status select (actions bar) ---------- */
.ud-status-select {
  height: var(--btn-md);
  padding: 0 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  min-width: 120px;
}
.ud-status-select:focus { border-color: var(--brand); }

/* Legacy sub-section styling so existing renderers (Installments, Notes, etc.)
   sit cleanly inside the new card shell until each is redesigned per-tab.      */
.ud-tab-panel .card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  margin-bottom: 16px;
  padding: 0;
}
.ud-tab-panel .card > .card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
}
.ud-tab-panel .card > .card-header h3 {
  font-size: var(--fs-15);
  font-weight: var(--fw-semibold);
}

@media (max-width: 1200px) {
  .unit-hero { grid-template-columns: 1fr; }
  .meta-grid { grid-template-columns: repeat(2, 1fr); }
  .ud-two-col { grid-template-columns: 1fr; }
}

/* ============================================================
   Installments tab — styles from
   _design/zain-os/project/Unit Detail - Installments.html.
   ============================================================ */

/* KPI summary strip */
.inst-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border-light);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: 16px;
}
.inst-summary .cell {
  background: var(--card);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.inst-summary .mk {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.inst-summary .mk::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-tertiary);
}
.inst-summary .cell.paid .mk::before    { background: #6A8A70; }
.inst-summary .cell.upcoming .mk::before{ background: var(--brand); }
.inst-summary .cell.overdue .mk::before { background: #C8553D; }
.inst-summary .mv {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.005em;
  font-variant-numeric: tabular-nums;
}
.inst-summary .cell.overdue .mv { color: #C8553D; }
.inst-summary .sub {
  font-size: 10.5px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* Progress bar */
.prog-bar {
  height: 6px;
  background: var(--hover);
  border-radius: var(--r-pill);
  overflow: hidden;
  display: flex;
  margin: 0;
}
.prog-bar .seg-paid     { background: #6A8A70; }
.prog-bar .seg-upcoming { background: var(--brand-dim); opacity: 0.55; }

/* Toolbar above the installments table */
.inst-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md) var(--r-md) 0 0;
  border-bottom: 0;
}
.inst-toolbar h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.inst-toolbar .count {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  margin-left: 6px;
}
.inst-toolbar .spacer { flex: 1; }

.tb-btn {
  height: 28px;
  padding: 0 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.tb-btn:hover { border-color: var(--brand-dim); color: var(--brand); }
.tb-btn svg { width: 11px; height: 11px; }
.tb-btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}
.tb-btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.tb-btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
}
.tb-btn.ghost:hover { background: var(--hover); color: var(--text); }
.tb-btn.danger-outline {
  border-color: var(--danger);
  color: var(--danger);
}
.tb-btn.danger-outline:hover { background: var(--danger-soft); }

/* Installments grid table */
.inst-table {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 0 0 var(--r-md) var(--r-md);
  overflow: hidden;
}
.inst-thead,
.inst-trow {
  display: grid;
  grid-template-columns: 56px 140px 1.1fr 1.3fr 130px 1.5fr 40px;
  gap: 0;
  padding: 10px 16px;
  align-items: center;
}
.inst-thead {
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  font-size: 10px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  font-weight: 500;
}
.inst-trow {
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  transition: background 120ms;
  cursor: pointer;
}
.inst-trow:last-child { border-bottom: 0; }
.inst-trow:hover { background: var(--hover); }
.inst-trow.overdue { background: rgba(200, 85, 61, 0.04); }
.inst-trow.overdue:hover { background: rgba(200, 85, 61, 0.08); }
.inst-trow.paid { opacity: 0.75; }

.i-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.i-num.dp { color: var(--brand); font-weight: 600; }

/* Type pills */
.type-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 112px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: 10.5px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid transparent;
  font-weight: 500;
  justify-self: start;
  box-sizing: border-box;
}
.type-pill.dp       { color: var(--brand); background: var(--brand-soft); border-color: rgba(232,97,58,0.25); }
.type-pill.inst     { color: var(--brand); background: transparent;        border-color: rgba(232,97,58,0.35); }
.type-pill.maint    { color: #A37936;     background: rgba(201,154,82,0.10); border-color: rgba(201,154,82,0.30); }
.type-pill.delivery { color: #8B6AA3;     background: rgba(139,106,163,0.10);border-color: rgba(139,106,163,0.30); }

.i-amount {
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}
.i-amount .cur {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-left: 4px;
  font-family: var(--font-mono);
  font-weight: 500;
}

.i-date {
  font-size: 12.5px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}
.i-date .rel {
  display: block;
  font-size: 10.5px;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.i-date .rel.due  { color: #A37936; }
.i-date .rel.over { color: #C8553D; font-weight: 600; }

/* Status pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 112px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: 10.5px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  justify-self: start;
  box-sizing: border-box;
}
.status-pill.paid     { color: #6A8A70; background: rgba(106,138,112,0.10); border: 1px solid rgba(106,138,112,0.30); }
.status-pill.upcoming { color: var(--brand); background: var(--brand-soft); border: 1px solid rgba(232,97,58,0.25); }
.status-pill.overdue  { color: #C8553D; background: rgba(200,85,61,0.10); border: 1px solid rgba(200,85,61,0.30); }

.i-notes {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.i-notes.empty { color: var(--text-tertiary); }

.row-menu {
  opacity: 0;
  transition: opacity 120ms;
  display: flex;
  justify-content: flex-end;
}
.inst-trow:hover .row-menu { opacity: 1; }
.row-menu button {
  width: 24px; height: 24px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  background: var(--card);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.row-menu button:hover { color: var(--brand); border-color: var(--brand-dim); }
.row-menu svg { width: 12px; height: 12px; }

/* ============================================================
   Auto-generated branded hero cover
   Renders in .hero-photo when the unit has no uploaded photos.
   Always replaced by the real image once one lands in unit-documents.
   ============================================================ */
.hero-photo.auto-brand {
  background:
    radial-gradient(circle at 82% 18%, rgba(232, 97, 58, 0.22), transparent 45%),
    radial-gradient(circle at 18% 85%, rgba(232, 97, 58, 0.06), transparent 55%),
    linear-gradient(180deg, #1b1715 0%, #141211 100%);
  display: block;
  padding: 0;
}
.hero-photo.auto-brand .hb-accent {
  position: absolute;
  top: 0; right: 0;
  width: 55%; height: 45%;
  background: radial-gradient(ellipse at top right, rgba(232, 97, 58, 0.18), transparent 68%);
  pointer-events: none;
}
.hero-photo.auto-brand .hb-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.2) 100%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.2) 100%);
}
.hero-photo.auto-brand .hb-watermark {
  position: absolute;
  top: 10%;
  right: 4%;
  font-family: var(--font-sans);
  font-size: clamp(140px, 22vw, 260px);
  font-weight: 700;
  color: var(--brand);
  opacity: 0.09;
  line-height: 0.85;
  letter-spacing: -0.05em;
  pointer-events: none;
  user-select: none;
}
.hero-photo.auto-brand .hb-content {
  position: absolute;
  left: 32px;
  top: 28px;
  right: 32px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 80%;
}
.hero-photo.auto-brand .hb-status {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.hero-photo.auto-brand .hb-status::before {
  content: '';
  width: 28px;
  height: 1px;
  background: var(--brand);
}
.hero-photo.auto-brand .hb-name {
  font-size: clamp(28px, 3.6vw, 46px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text);
  margin: 0 0 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hero-photo.auto-brand .hb-code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}
.hero-photo.auto-brand .hb-compound {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.hero-photo.auto-brand .hb-specs {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-wrap: wrap;
}
.hero-photo.auto-brand .hb-specs .hb-dot { color: var(--text-tertiary); opacity: 0.6; }
.hero-photo.auto-brand .hb-brand {
  position: absolute;
  bottom: 20px;
  left: 32px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: -0.005em;
  z-index: 2;
  font-family: var(--font-sans);
}
.hero-photo.auto-brand .hb-brand span { color: var(--brand); }

/* Reposition the "auto-generated" label so it doesn't collide with the wordmark */
.hero-photo.auto-brand .photo-label {
  top: auto;
  bottom: 18px;
  left: auto;
  right: 18px;
  font-size: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ============================================================
   Photos tab — dropzone, photo tiles, cover selection
   ============================================================ */
.photos-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 28px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 120ms, background 120ms, color 120ms;
  margin-bottom: 18px;
}
.photos-dropzone:hover,
.photos-dropzone.dragover {
  border-color: var(--brand);
  background: var(--brand-subtle);
  color: var(--brand);
}
.photos-dropzone svg { color: inherit; }
.photos-dropzone-title { font-size: 13px; font-weight: 500; }
.photos-dropzone-hint { font-size: 11px; color: var(--text-tertiary); font-family: var(--font-mono); }

.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.photo-tile {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-sm);
  overflow: hidden;
  transition: border-color 120ms;
}
.photo-tile:hover { border-color: var(--border); }
.photo-tile.is-cover { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }

.photo-tile-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--bg);
  cursor: pointer;
  overflow: hidden;
}
.photo-tile-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cover-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: var(--r-pill);
  font-weight: 600;
}

.auto-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 80% 20%, rgba(232, 97, 58, 0.22), transparent 55%),
    linear-gradient(180deg, #1b1715 0%, #141211 100%);
  position: relative;
  cursor: default;
}
.auto-tile-z {
  font-size: 80px;
  font-weight: 700;
  color: var(--brand);
  opacity: 0.22;
  letter-spacing: -0.04em;
  line-height: 1;
  user-select: none;
}
.auto-tile-label {
  position: absolute;
  bottom: 10px;
  left: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

.photo-tile-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--border-light);
  background: var(--card);
}
.tile-btn {
  flex: 1;
  height: 28px;
  padding: 0 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: color 120ms, border-color 120ms, background 120ms;
}
.tile-btn:hover { border-color: var(--brand-dim); color: var(--brand); }
.tile-btn.active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}
.tile-icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms, border-color 120ms, background 120ms;
}
.tile-icon-btn:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.tile-icon-btn svg { width: 13px; height: 13px; }

/* ============================================================
   Clients / Notes / Documents / Presentation / Share subtabs
   ============================================================ */

/* ----- Shared KPI strip (Clients + Documents) ----- */
.clients-strip,
.docs-strip {
  display: grid;
  gap: 1px;
  background: var(--border-light);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: 16px;
}
.clients-strip { grid-template-columns: repeat(5, 1fr); }
.docs-strip    { grid-template-columns: repeat(6, 1fr); }
.cs-cell, .ds-cell {
  background: var(--card);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cs-k, .ds-k {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-weight: 500;
}
.cs-v, .ds-v {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.005em;
  font-variant-numeric: tabular-nums;
}

/* ----- Shared text inputs used inside ud cards ----- */
.ud-input {
  width: 100%;
  height: var(--input-md, 34px);
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  transition: border-color var(--dur-default) var(--ease);
}
.ud-input:hover { border-color: var(--brand-dim); }
.ud-input:focus { border-color: var(--brand); }
.ud-input::placeholder { color: var(--text-tertiary); }
select.ud-input { cursor: pointer; }
.ud-textarea {
  height: auto;
  min-height: 84px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}

/* ----- Clients tab ----- */
.assign-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
}
.assign-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-tertiary);
}
.assign-hint strong { color: var(--text-secondary); }

.clients-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.cc-card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cc-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
}
.cc-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--hover);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cc-name-col { min-width: 0; flex: 1; }
.cc-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cc-tags {
  display: inline-flex;
  gap: 6px;
  margin-top: 3px;
  flex-wrap: wrap;
}
.cc-tag {
  font-size: 10px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--hover);
  color: var(--text-secondary);
  font-weight: 500;
}
.cc-tag-status { background: var(--brand-subtle); color: var(--brand); }

.cc-score {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.cc-score.cold { background: var(--hover); color: var(--text-tertiary); }
.cc-score.warm { background: rgba(212, 165, 116, 0.2); color: #d4a574; }

.cc-meta {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.cc-meta-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  font-size: 12px;
  align-items: baseline;
}
.cc-meta-row .k {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10.5px;
}
.cc-meta-row .v {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}
.cc-meta-row .v.mono { font-family: var(--font-mono); font-size: 11.5px; }
.cc-meta-row .v.ai-on     { color: #7ab28f; }
.cc-meta-row .v.ai-paused { color: #d4a574; }
.cc-meta-row .v.ai-off    { color: var(--danger); }

.cc-actions {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
}
.cc-actions .ud-btn { flex: 1; min-width: 0; font-size: 11.5px; padding: 0 10px; }

/* ----- Notes tab ----- */
.note-composer { display: flex; flex-direction: column; gap: 10px; }
.note-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.note-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.note-hint .kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
}
.notes-list {
  display: flex;
  flex-direction: column;
  padding: 4px 0;
}

/* ----- Documents tab ----- */
.docs-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 28px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 18px;
  transition: border-color 120ms, background 120ms, color 120ms;
}
.docs-dropzone:hover,
.docs-dropzone.dragover {
  border-color: var(--brand);
  background: var(--brand-subtle);
  color: var(--brand);
}
.docs-dropzone-title { font-size: 13px; font-weight: 500; }
.docs-dropzone-hint { font-size: 11px; color: var(--text-tertiary); font-family: var(--font-mono); }

.docs-table {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  overflow: hidden;
}
.docs-thead,
.docs-row {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) 140px 100px 140px 90px;
  gap: 12px;
  padding: 10px 16px;
  align-items: center;
}
.docs-thead {
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  font-size: 10px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  font-weight: 500;
}
.docs-row {
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  transition: background 120ms;
}
.docs-row:last-child { border-bottom: 0; }
.docs-row:hover { background: var(--hover); }

.d-file {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.d-icon {
  font-size: 14px;
  flex-shrink: 0;
  opacity: 0.7;
}
.d-name {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.d-size.mono {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.d-date {
  font-size: 12px;
  color: var(--text-secondary);
}
.d-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ----- Presentation tab ----- */
.ps-status {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-radius: var(--r-sm);
  margin-bottom: 14px;
}
.ps-status svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; }
.ps-status.ps-ok {
  background: rgba(106, 138, 112, 0.08);
  border: 1px solid rgba(106, 138, 112, 0.25);
  color: #7ab28f;
}
.ps-status.ps-empty {
  background: var(--bg);
  border: 1px dashed var(--border);
  color: var(--text-secondary);
}
.ps-title { font-size: 13px; font-weight: 600; color: var(--text); }
.ps-sub { font-size: 12px; color: var(--text-secondary); margin-top: 3px; line-height: 1.45; }

.ps-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pdf-history-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
}
.pdf-history-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--brand-subtle);
  border: 1px solid var(--brand-dim);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pdf-history-icon svg { width: 16px; height: 16px; }
.pdf-history-info { min-width: 0; }
.pdf-history-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-history-sub { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.ps-how {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ps-how li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.ps-how li strong { color: var(--text); font-weight: 600; }
.ps-step {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ps-safety {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--brand-subtle);
  border: 1px solid var(--brand-dim);
  border-radius: var(--r-sm);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
}
.ps-safety svg { width: 16px; height: 16px; color: var(--brand); flex-shrink: 0; margin-top: 1px; }
.ps-safety strong { color: var(--brand); font-weight: 600; }

/* ----- Share tab ----- */
.share-link-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
}
.share-link-row input.ud-input {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
}
.share-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.5;
}

.share-via-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.share-via-grid .ud-btn { justify-content: center; }

.share-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.share-qr {
  width: 220px; height: 220px;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-sm);
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.share-qr img { width: 100%; height: 100%; display: block; }
.share-qr-hint {
  font-size: 11.5px;
  color: var(--text-tertiary);
  text-align: center;
  max-width: 220px;
  line-height: 1.45;
}

/* Responsive clamp for narrow viewports */
@media (max-width: 1200px) {
  .clients-strip { grid-template-columns: repeat(2, 1fr); }
  .docs-strip    { grid-template-columns: repeat(3, 1fr); }
  .assign-row    { grid-template-columns: 1fr; }
  .share-link-row { grid-template-columns: 1fr; }
  .docs-thead, .docs-row { grid-template-columns: minmax(0, 2fr) 100px 80px 80px; }
  .docs-thead > :nth-child(4), .docs-row > :nth-child(4) { display: none; }
}

/* ----- Fill the Upcoming-installments card to the right column's height ----- */
.ud-two-col > .ud-card:first-child {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ud-two-col > .ud-card:first-child .ud-card-head { flex-shrink: 0; }
.ud-two-col > .ud-card:first-child .ud-timeline-fill {
  flex: 1 1 0;          /* basis 0 so 30 items don't push the card height */
  min-height: 0;
  overflow: hidden;     /* partial overflow clipped; JS fits exactly */
}

/* ----- Profit row: icon on the LEFT, number on the RIGHT ----- */
#profit-line .v { justify-self: end; }
#profit-line .profit-display {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.005em;
}
#profit-line .profit-edit-trigger {
  order: -1;             /* icon before number */
  margin-left: 0;
  margin-right: 0;
}
.profit-edit-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.profit-edit-inline .profit-input {
  height: 28px;
  padding: 0 8px;
  background: var(--bg);
  border: 1px solid var(--brand);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  width: 130px;
  outline: none;
  text-align: right;
}

/* ============================================================
   Share card — branded exportable image (Plus Jakarta Sans,
   dark gradient, orange accents, matches the rest of Zain OS).
   ============================================================ */
.share-modal { display: flex; flex-direction: column; gap: 18px; }
.share-modal-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.share-modal-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  max-width: 420px;
  line-height: 1.55;
}
.share-modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.share-modal-preview {
  display: flex;
  justify-content: center;
  padding: 6px 0 4px;
}

.share-card {
  position: relative;
  width: 440px;
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at 82% 18%, rgba(232, 97, 58, 0.22), transparent 45%),
    radial-gradient(circle at 18% 85%, rgba(232, 97, 58, 0.06), transparent 55%),
    linear-gradient(180deg, #1b1715 0%, #141211 100%);
  color: var(--text);
  font-family: var(--font-sans);
  display: flex;
  flex-direction: column;
  padding: 30px 32px;
  box-sizing: border-box;
}
.share-card-accent {
  position: absolute; top: 0; right: 0;
  width: 55%; height: 45%;
  background: radial-gradient(ellipse at top right, rgba(232, 97, 58, 0.20), transparent 68%);
  pointer-events: none;
}
.share-card-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0.15) 100%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0.15) 100%);
}
.share-card-watermark {
  position: absolute;
  top: -24px; right: -10px;
  font-family: var(--font-sans);
  font-size: 240px;
  font-weight: 700;
  color: var(--brand);
  opacity: 0.08;
  line-height: 0.85;
  letter-spacing: -0.05em;
  pointer-events: none;
  user-select: none;
}

.share-card-head {
  position: relative; z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 24px;
}
.share-card-logo { display: inline-flex; align-items: center; gap: 10px; }
.share-card-logomark {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.share-card-wordmark {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
}
.share-card-wordmark span { color: var(--brand); }
.share-card-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brand);
  padding: 4px 10px;
  background: var(--brand-subtle);
  border: 1px solid var(--brand-dim);
  border-radius: var(--r-pill);
}

.share-card-body {
  position: relative; z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.share-card-name {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--text);
  margin: 0 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.share-card-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.share-card-specs {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.share-card-specs .sc-dot { opacity: 0.5; }

.share-card-price {
  margin-top: auto;
  padding: 16px 18px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
}
.scp-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}
.scp-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.scp-k {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  margin-bottom: 4px;
}
.scp-v {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.01em;
  color: var(--text);
}
.scp-v.scp-v-sm { font-size: 15px; }
.scp-v.scp-brand { color: var(--brand); }

.share-card-foot {
  position: relative; z-index: 2;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: center;
  color: var(--text-tertiary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ----- Installments toolbar Export dropdown ----- */
.tb-export-wrap { position: relative; }
.tb-export-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px;
  min-width: 220px;
  z-index: 20;
  box-shadow: var(--shadow-md);
  display: none;
}
.tb-export-menu.on { display: block; }
.tb-export-menu button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}
.tb-export-menu button:hover { background: var(--hover); }
.tb-export-menu button:hover .tb-fmt { color: var(--brand); }
.tb-fmt { font-size: 12.5px; font-weight: 600; color: var(--text); }
.tb-fmt-sub { font-size: 10.5px; color: var(--text-tertiary); font-family: var(--font-mono); }

/* ============================================================
   Responsive (tablet / phone / touch) — additive only.
   Multi-column info layouts collapse to 1 col at ≤640px.
   Photo grid shrinks 4→3→2 as width drops.
   Info-dense tables (installments, docs) use horizontal scroll
   (Pattern A) so columns stay readable.
   ============================================================ */
@media (max-width: 1024px) {
  /* Page header wraps fully */
  .ud-page-header { flex-wrap: wrap; gap: 12px; }
  .ud-actions { flex-wrap: wrap; }

  /* Hero stays 1-col below the existing 1200px rule; nothing to change here */

  /* Subtabs scroll horizontally so they all stay reachable */
  .ud-subtabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .ud-subtab { white-space: nowrap; flex-shrink: 0; }

  /* Two-col → single col at this width too (was 1200px) */
  .ud-two-col { grid-template-columns: 1fr; }
  .meta-grid { grid-template-columns: repeat(2, 1fr); }

  /* Hover-reveal row menu visible by default on tablet/touch */
  .row-menu { opacity: 1; }

  /* Installments table: horizontal scroll wrapper */
  .inst-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .inst-thead, .inst-trow { min-width: 880px; }

  /* Docs table: horizontal scroll */
  .docs-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .docs-thead, .docs-row { min-width: 640px; }

  /* Clients / docs KPI strips: 2-up */
  .clients-strip { grid-template-columns: repeat(2, 1fr); }
  .docs-strip    { grid-template-columns: repeat(3, 1fr); }

  /* Action grid stays 2-up at this width */
  .photos-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (max-width: 640px) {
  /* Header */
  .ud-page-header { gap: 10px; }
  .ud-title { font-size: 19px; }
  .ud-actions { width: 100%; }
  .ud-actions .ud-btn { flex: 1 1 auto; }

  /* Hero / price-card stack already at 1200px; tighten paddings */
  .price-card-header { padding: 12px 14px; }
  .price-row { padding: 10px 14px; }
  .price-row.total .v { font-size: 18px; }
  .ud-card-head { padding: 12px 14px; }
  .ud-card-body { padding: 12px 14px; }

  /* Meta grid → 1 col */
  .meta-grid { grid-template-columns: 1fr; }

  /* Installments summary → 2 col on phone */
  .inst-summary { grid-template-columns: repeat(2, 1fr); }

  /* Installments toolbar wraps */
  .inst-toolbar { flex-wrap: wrap; gap: 8px; }
  .inst-toolbar h3 { width: 100%; }
  .inst-toolbar .spacer { display: none; }
  .tb-btn { flex: 1 1 auto; }

  /* Photo grid → 2 cols on phone */
  .photos-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .photo-tile-foot { flex-wrap: wrap; gap: 4px; padding: 6px 8px; }

  /* Clients / docs KPI strips → 1 col stripes */
  .clients-strip { grid-template-columns: 1fr 1fr; }
  .docs-strip    { grid-template-columns: 1fr 1fr; }

  /* Client cards: full width naturally; tighten heads */
  .clients-grid { grid-template-columns: 1fr; }
  .cc-head { padding: 12px 14px; }
  .cc-meta { padding: 10px 14px; }
  .cc-meta-row { grid-template-columns: 80px 1fr; }
  .cc-actions { padding: 10px 14px; flex-wrap: wrap; }
  .cc-actions .ud-btn { flex: 1 1 calc(50% - 4px); }

  /* Action grid: keep 2-up but tighter */
  .action-grid { gap: 8px; }

  /* Share grid keeps auto-fill; share link row → 1-col */
  .share-link-row { grid-template-columns: 1fr; }
  .share-via-grid { grid-template-columns: repeat(2, 1fr); }

  /* Presentation tab spacing */
  .ps-status { padding: 12px 14px; }
  .ps-actions { gap: 6px; }
  .ps-actions .ud-btn { flex: 1 1 auto; }

  /* Status select fills width */
  .ud-status-select { width: 100%; }
}

@media (hover: none) and (pointer: coarse) {
  /* Tap targets */
  .ud-btn,
  .tb-btn,
  .tile-btn,
  .tile-icon-btn,
  .ud-subtab,
  .row-menu button { min-height: 36px; }
  .tile-icon-btn { min-width: 36px; }

  /* Inputs ≥16px to prevent iOS zoom */
  .ud-input,
  .ud-textarea,
  .ud-status-select,
  select.ud-input { font-size: 16px; }

  /* Hover-reveal affordances always visible */
  .row-menu { opacity: 1; }
}

/* ============================================================
   Additional refinements — share card scaling, pdf-history row,
   export menu positioning, photo tile foot, inline editor inputs.
   The share card is a fixed 440px export target that overflows
   on narrow phones; we visually scale the preview but keep the
   underlying dimensions so html2canvas still exports 1080×1080.
   ============================================================ */
@media (max-width: 1024px) {
  /* Compound photo grid: 4-col density → 3-col on tablet */
  .photos-grid { grid-template-columns: repeat(3, 1fr); }

  /* PDF history row: collapse trailing buttons to a single trailing slot */
  .pdf-history-row { grid-template-columns: auto 1fr auto; column-gap: 10px; row-gap: 6px; }
  .pdf-history-row .ud-btn:nth-of-type(2) { grid-column: 2 / -1; justify-self: stretch; }

  /* Export dropdown inside installments toolbar: anchor to its wrap */
  .tb-export-menu { right: auto; left: 0; min-width: 180px; }

  /* Notes composer textarea: roomier on touch */
  .ud-textarea { min-height: 96px; }

  /* QR slightly smaller so it doesn't crowd the modal */
  .share-qr { width: 200px; height: 200px; }
  .share-qr-hint { max-width: 200px; }
}

@media (max-width: 640px) {
  /* Back link: extra tappable padding */
  .ud-back { padding: 6px 8px 6px 0; }

  /* Subtabs row: fade-to-edge hint */
  .ud-subtabs { margin-bottom: 16px; }
  .ud-subtab { padding: var(--sp-3) var(--sp-3); font-size: var(--fs-12); }

  /* Hero photo: shorter for portrait phones (still aspect-locked) */
  .unit-hero { gap: 14px; margin-bottom: 16px; }

  /* Price card: tighten breakdown bar margins */
  .breakdown-bar { margin: 10px 14px 14px; }
  .price-row .v { font-size: 14px; }

  /* Timeline rows: stack date above title to free horizontal room */
  .timeline-item { grid-template-columns: 1fr auto; row-gap: 4px; padding: 12px 14px; }
  .timeline-item .date { grid-column: 1 / -1; font-size: 10.5px; }
  .timeline-item .amount { font-size: 13px; }

  /* Action grid: 1-up on narrow phones for full-width buttons */
  .action-grid { grid-template-columns: 1fr; }

  /* Inline profit editor narrower */
  .profit-edit-inline .profit-input { width: 100px; font-size: 16px; }

  /* PDF history: trailing buttons full row below the name */
  .pdf-history-row { grid-template-columns: auto 1fr; row-gap: 8px; }
  .pdf-history-row > .ud-btn { grid-column: 1 / -1; }

  /* Photos grid: keep 2-col already set; rich foot wraps */
  .photo-tile-foot .tile-btn { font-size: 11px; }

  /* Notes list / docs row tighter padding */
  .docs-thead { display: none; }
  .docs-row { font-size: 12px; }

  /* Share modal — scale the fixed-width 440px card to fit phone */
  .share-modal-preview { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 6px 4px; }
  .share-modal-actions { width: 100%; }
  .share-modal-actions .ud-btn { flex: 1 1 calc(50% - 4px); }
  /* Visually shrink the preview only; preserve underlying 440×440
     so html2canvas exports the full-resolution 1080×1080 PNG.        */
  .share-card { transform: scale(calc((100vw - 48px) / 440)); transform-origin: top center; margin-bottom: calc((100vw - 48px) / 440 * 440 - 440px); }

  /* Compound auto-brand hero text scales already via clamp(); nothing to do */

  /* Status select inside header sits full-width via .ud-status-select rule above */

  /* Installments toolbar Export menu: anchor to toolbar edges */
  .tb-export-menu { left: 0; right: 0; min-width: 0; }

  /* Documents table: hide size column header already, drop date column */
  .docs-thead, .docs-row { grid-template-columns: minmax(0, 1.6fr) 80px 70px; min-width: 520px; }
  .docs-thead > :nth-child(3), .docs-row > :nth-child(3) { display: none; }
  .docs-thead > :nth-child(4), .docs-row > :nth-child(4) { display: none; }

  /* Presentation tab: how-list condensed step bubble */
  .ps-how li { grid-template-columns: 24px 1fr; gap: 8px; font-size: 12px; }
  .ps-safety { padding: 10px 12px; gap: 8px; font-size: 11.5px; }

  /* Client card actions: 1-col stack of full-width buttons */
  .cc-actions .ud-btn { flex: 1 1 100%; }
}

@media (hover: none) and (pointer: coarse) {
  /* Drag/select affordances always visible on touch */
  .profit-edit-trigger { color: var(--brand); }

  /* Subtabs scrollable with momentum already (above); add larger hit area */
  .ud-subtab { padding-top: 12px; padding-bottom: 12px; }

  /* Toolbar buttons larger so finger taps don't miss */
  .tb-btn { min-height: 36px; padding: 0 14px; }

  /* Inline-editor inputs ≥16px to block iOS zoom on focus */
  .profit-edit-inline .profit-input,
  .inst-edit-input { font-size: 16px; }

  /* Photo tile delete icon button stays visible (no hover state) */
  .tile-icon-btn { opacity: 1; }
}
