/* Site Builder — Customers
   The Customers page (#/customers, from the side menu — shell.js swaps it in
   for the sites) and the customer drawer (customers.js). The page sits on the
   black beside the menu: a card per customer in the sites' own white, square
   cut; the drawer reuses the CRM's glass drawer (crm.css) and only adds what
   a customer has that a lead does not. */

/* ---- the page ---- */
.cust-rail { display: flex; flex-direction: column; min-height: 0; }
.cust-rail-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cust-rail-head h1 { margin: 0 0 10px; }
.cust-rail .cat-count { color: rgba(255, 255, 255, .8); background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .16); margin-bottom: 10px; }
.cust-add { margin: 0 0 10px auto; }
.cust-add svg { width: 13px; height: 13px; }
.cust-rail .sub { max-width: 70ch; margin-bottom: 20px; }

.cust-search { position: relative; display: block; max-width: 360px; margin: 0 0 16px; }
.cust-search svg { position: absolute; left: 13px; top: 50%; width: 14px; height: 14px; transform: translateY(-50%); color: rgba(255, 255, 255, .6); pointer-events: none; }
.cust-search input {
  padding: 9px 14px 9px 36px; font-size: 13.5px; border-radius: 999px;
  background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .2); color: #FFFFFF;
}
.cust-search input::placeholder { color: rgba(255, 255, 255, .55); }
.cust-search input:focus { background: rgba(255, 255, 255, .14); border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245, 197, 24, .18); }

.cust-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px;
}
.cust-item {
  position: relative; width: 100%; height: 100%; display: flex; align-items: center; gap: 14px;
  padding: 18px 18px 18px 16px; border: 1px solid rgba(255, 255, 255, .2); border-radius: 0;
  background: rgba(255, 255, 255, .94); color: var(--ink); font: inherit; text-align: left; cursor: pointer;
  box-shadow: var(--shadow-rest);
  transition: transform .32s var(--ease-spring), box-shadow .32s var(--ease-out), background .16s var(--ease-out), border-color .16s var(--ease-out);
}
.cust-item:hover {
  background: #FFFFFF; border-color: rgba(245, 197, 24, .6); transform: translateY(-3px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .4), 0 4px 40px rgba(123, 30, 46, .3);
}
.cust-item:active { transform: translateY(0) scale(.985); box-shadow: var(--shadow-rest); transition-duration: .06s; }
.cust-item.is-open { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 26px rgba(245, 197, 24, .25); }
.cust-item.is-over { background: #FFF8DC; border: 1px dashed rgba(154, 106, 18, .7); }
.cust-item .crm-avatar {
  width: 42px; height: 42px; flex: none; font: 400 12px var(--wide, var(--sans)); letter-spacing: .04em; color: #FFFFFF;
  background: #000000; box-shadow: inset 0 0 0 1px rgba(245, 197, 24, .35);
}
.cust-item.is-open .crm-avatar { background: var(--accent); box-shadow: inset 0 0 0 1px rgba(245, 197, 24, .6); }
.cust-item-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; line-height: 1.3; }
.cust-item-txt b { font: 700 15px var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-item-txt span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* something overdue — a payment or a to-do — marks the card in amber */
.cust-late { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(154, 106, 18, .18); }
.cust-none { padding: 10px 2px; font-size: 13px; color: rgba(255, 255, 255, .7); }
.cust-empty { margin: 4px 0 0; max-width: 60ch; font-size: 14px; line-height: 1.5; color: rgba(255, 255, 255, .72); }
.cust-empty b { color: #FFFFFF; }

/* ---- the drawer ---- */
#view-home.cust-open #cust-scrim { opacity: 1; pointer-events: auto; }
#view-home.cust-open #cust-drawer { transform: none; visibility: visible; transition: transform .42s var(--ease-out); }
.cust-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.cust-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.cust-stat {
  display: flex; flex-direction: column; gap: 1px; min-width: 0;
  padding: 9px 11px; border-radius: 14px;
  background: rgba(255, 255, 255, .6); border: 1px solid var(--line-soft);
}
.cust-stat .lab { font-size: 10px; }
.cust-stat b { font: 700 16px var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-stat-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-stat.is-paid b { color: var(--ok); }
.cust-stat.is-owed.is-late { background: rgba(154, 106, 18, .08); border-color: rgba(154, 106, 18, .3); }
.cust-stat.is-owed.is-late b, .cust-stat.is-owed.is-late .cust-stat-sub { color: var(--warn); }

/* small round × on a row */
.cust-x { flex: none; padding: 0; width: 24px; height: 24px; justify-content: center; font-size: 16px; line-height: 1; opacity: .55; }
.cust-x:hover { opacity: 1; color: var(--danger-ink); }

/* sites */
.cust-sites { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cust-sites:empty { display: none; }
.cust-site {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px;
  background: rgba(255, 255, 255, .6); border: 1px solid var(--line-soft); border-radius: 12px;
}
.cust-site-name { flex: 1; min-width: 0; font: 700 13px var(--display); color: var(--ink); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-site-name:hover { color: var(--accent); }
.cust-tag { font: 600 10.5px var(--sans); color: var(--muted); padding: 1px 7px; border-radius: 999px; background: rgba(26, 26, 26, .06); }
.cust-attach select { font-size: 13px; padding: 7px 12px; }
#cust-dr-sites-empty { padding: 6px 0 12px; text-align: left; }

/* add a to-do / a payment: one row of fields and the button */
.cust-row-form { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.cust-row-form input { font-size: 13px; padding: 7px 11px; }
.cust-row-form input[type=date] { flex: 0 0 142px; }
.cust-row-form .btn { flex: none; }
.cust-pay-form { flex-wrap: wrap; }
.cust-pay-form .crm-money-in { flex: 0 0 120px; }
.cust-pay-form #cust-pay-note { flex: 1 1 160px; }
.cust-pay-paid { padding: 6px 11px; font-size: 12.5px; }

/* to-dos */
.cust-todos, .cust-pays { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.cust-todo { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line-soft); }
.cust-todo:first-child { border-top: 0; }
.cust-tick { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 13.5px; line-height: 1.4; }
.cust-tick input { width: 16px; height: 16px; margin: 2px 0 0; flex: none; cursor: pointer; }
.cust-tick span { word-break: break-word; transition: color .2s var(--ease-out); }
.cust-todo.is-done .cust-tick span { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(46, 46, 46, .45); }
.cust-due, .cust-by { flex: none; font: 500 11px var(--mono); color: var(--muted); padding: 1px 7px; border-radius: 999px; background: rgba(26, 26, 26, .05); }
.cust-due.is-today { color: var(--accent-deep); background: var(--accent-soft); }
.cust-due.is-late { color: var(--warn); background: rgba(154, 106, 18, .12); }
.cust-by { background: none; padding: 0; }

/* payments */
.cust-paybar { height: 6px; border-radius: 999px; background: rgba(26, 26, 26, .08); overflow: hidden; margin: 0 0 12px; }
.cust-paybar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #0B7A53, #12A06E); transition: width .5s var(--ease-out); }
.cust-pay { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line-soft); }
.cust-pay:first-child { border-top: 0; }
.cust-pay-amt { flex: 0 0 auto; min-width: 84px; font: 600 13px var(--mono); font-variant-numeric: tabular-nums; }
.cust-pay-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; font-size: 13px; }
.cust-pay-txt > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-pay-when { font-size: 11.5px; color: var(--muted); }
.cust-pay-state {
  flex: none; font: 700 10.5px var(--sans); letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .7); color: var(--muted);
  transition: transform .32s var(--ease-spring), background .16s var(--ease-out), border-color .16s var(--ease-out);
}
.cust-pay-state:hover { transform: translateY(-1px); border-color: rgba(123, 30, 46, .45); background: #FFFFFF; }
.cust-pay-state:active { transform: scale(.95); transition-duration: .06s; }
.cust-pay.is-paid .cust-pay-state { color: var(--ok); background: rgba(14, 138, 95, .1); border-color: rgba(14, 138, 95, .35); }
.cust-pay.is-late .cust-pay-state { color: var(--warn); background: rgba(154, 106, 18, .1); border-color: rgba(154, 106, 18, .4); }
.cust-pay.is-late .cust-pay-when { color: var(--warn); }

/* contract */
.cust-contract-status { margin-bottom: 12px; width: fit-content; max-width: 100%; flex-wrap: wrap; }
.cust-contract-status .btn { padding: 5px 12px; font-size: 12px; box-shadow: none; }
.cust-wide { grid-column: 1 / -1; }
.cust-contract textarea { font-size: 13px; padding: 8px 12px; resize: vertical; }
.cust-ct-open { display: inline-block; margin-top: 10px; font-size: 12.5px; font-weight: 600; color: var(--accent); text-decoration: none; }
.cust-ct-open:hover { text-decoration: underline; }

/* ---- narrower screens ---- */
@media (max-width: 760px) {
  .cust-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .cust-row-form { flex-wrap: wrap; }
  .cust-row-form input[type=date] { flex: 1 1 140px; }
  .cust-drawer input, .cust-drawer textarea, .cust-drawer select { font-size: 16px; }   /* stops iOS zooming on focus */
}
@media (prefers-reduced-motion: reduce) {
  .cust-item:hover, .cust-item:active, .cust-pay-state:hover, .cust-pay-state:active { transform: none; }
}
