/* ==========================================================================
   ui.css — shared component layer (V1.78)
   Mobile-first. Loaded after app.css in all three layouts.
   Everything here is prefixed .u- so it cannot collide with existing classes
   or with Bootstrap utilities.
   ========================================================================== */

:root{
  --u-ink:#0B1F1D;
  --u-teal:#0E5C57;
  --u-teal-deep:#0A2E2B;
  --u-teal-soft:#E7F0EE;
  --u-paper:#F4F6F5;
  --u-card:#FFFFFF;
  --u-line:#E1E7E5;
  --u-muted:#63736F;
  --u-signal:#C2410C;          /* urgency only — never decorative */
  --u-signal-soft:#FFF1E9;
  --u-good:#0E7C5A;
  --u-good-soft:#E6F4EE;
  --u-brass:#A87C29;
  --u-r:14px;
  --u-r-sm:9px;
  --u-shadow:0 1px 2px rgba(11,31,29,.04);
  --u-tap:44px;                /* minimum touch target */
}

/* ---------- primitives ---------- */
.u-card{
  background:var(--u-card);border:1px solid var(--u-line);
  border-radius:var(--u-r);box-shadow:var(--u-shadow);
}
.u-card + .u-card{margin-top:14px}
.u-card-head{
  display:flex;align-items:center;gap:10px;
  padding:13px 15px;border-bottom:1px solid var(--u-line);
}
.u-card-head h3{font-size:14.5px;font-weight:700;margin:0;letter-spacing:-.2px}
.u-card-head .u-link{margin-left:auto;font-size:12.5px;color:var(--u-teal);font-weight:650;text-decoration:none}
.u-card-body{padding:15px}
.u-num{font-variant-numeric:tabular-nums;letter-spacing:-.5px}

.u-pill{font-size:10.5px;font-weight:700;padding:2px 8px;border-radius:20px;display:inline-block;white-space:nowrap}
.u-pill--live{background:var(--u-good-soft);color:var(--u-good)}
.u-pill--wait{background:var(--u-signal-soft);color:var(--u-signal)}
.u-pill--quiet{background:#F0F2F1;color:var(--u-muted)}

.u-delta{font-size:11.5px;font-weight:650;padding:2px 6px;border-radius:6px}
.u-delta--up{background:var(--u-good-soft);color:var(--u-good)}
.u-delta--down{background:var(--u-signal-soft);color:var(--u-signal)}

/* ---------- KPI grid: 2-up on phones, more as space allows ---------- */
.u-kpis{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
@media(min-width:700px){.u-kpis{grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}}
@media(min-width:1100px){.u-kpis--4{grid-template-columns:repeat(4,minmax(0,1fr))}}

.u-kpi{
  background:var(--u-card);border:1px solid var(--u-line);border-radius:var(--u-r);
  padding:13px;box-shadow:var(--u-shadow);min-width:0;
}
.u-kpi-top{display:flex;align-items:center;gap:7px;margin-bottom:7px}
.u-kpi-label{font-size:11.5px;color:var(--u-muted);font-weight:650;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.u-kpi-val{font-size:23px;font-weight:700;line-height:1}
@media(min-width:700px){.u-kpi{padding:15px 16px}.u-kpi-val{font-size:26px}}
.u-kpi-sub{font-size:11.5px;color:var(--u-muted);margin-top:6px}
.u-kpi-ico{width:26px;height:26px;border-radius:8px;background:var(--u-teal-soft);color:var(--u-teal);display:grid;place-items:center;font-size:13px;flex:0 0 26px}
.u-kpi-ico--wait{background:var(--u-signal-soft);color:var(--u-signal)}

/* sparkline */
.u-spark{display:flex;align-items:flex-end;gap:2px;height:30px;margin-top:11px}
.u-spark i{flex:1;background:#C8DDD9;border-radius:2px 2px 0 0;min-height:2px}
.u-spark i.on{background:var(--u-teal)}

/* ---------- attention queue (the dashboard hero) ---------- */
.u-queue-meta{
  padding:9px 15px;background:#FAFBFB;border-bottom:1px solid var(--u-line);
  font-size:11.5px;color:var(--u-muted);
}
.u-queue-meta b{color:var(--u-ink)}
.u-lead{padding:12px 15px;border-bottom:1px solid #F0F3F2}
.u-lead:last-child{border-bottom:0}
.u-lead-top{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.u-age{font-size:11px;font-weight:700;padding:2px 7px;border-radius:6px;background:#F0F2F1;color:var(--u-muted)}
.u-age--hot{background:var(--u-signal-soft);color:var(--u-signal)}
.u-lead-name{font-size:13.5px;font-weight:650}
.u-lead-msg{font-size:12.5px;color:var(--u-muted);margin-top:5px;line-height:1.45}
.u-lead-for{font-size:11px;color:#8A9793;margin-top:5px}
.u-lead-act{display:flex;gap:8px;margin-top:10px}
.u-lead-act .u-btn{flex:1}
@media(min-width:760px){
  .u-lead{display:flex;align-items:center;gap:14px}
  .u-lead-body{flex:1;min-width:0}
  .u-lead-msg{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:2px}
  .u-lead-act{margin-top:0;flex:0 0 auto}
  .u-lead-act .u-btn{flex:0 0 auto}
}

/* ---------- buttons: always tappable ---------- */
.u-btn{
  display:inline-flex;align-items:center;justify-content:center;gap:6px;
  min-height:var(--u-tap);padding:0 15px;border-radius:var(--u-r-sm);
  font-size:13px;font-weight:650;border:1px solid transparent;text-decoration:none;cursor:pointer;
}
.u-btn--primary{background:var(--u-teal);color:#fff}
.u-btn--wa{background:var(--u-good);color:#fff}
.u-btn--ghost{background:#fff;border-color:var(--u-line);color:var(--u-muted)}
.u-btn--sm{min-height:36px;font-size:12.5px;padding:0 12px}

/* ---------- list rows ---------- */
.u-row{display:flex;align-items:center;gap:11px;padding:11px 0;border-bottom:1px solid #F2F5F4;min-width:0}
.u-row:last-child{border-bottom:0}
.u-thumb{
  width:40px;height:40px;border-radius:10px;background:#E9EEED;flex:0 0 40px;
  display:grid;place-items:center;color:#7C8B87;font-size:15px;overflow:hidden;
}
.u-thumb img{width:100%;height:100%;object-fit:cover}
.u-row-main{min-width:0;flex:1}
.u-row-title{font-size:13.5px;font-weight:650;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.u-row-meta{font-size:11.5px;color:var(--u-muted);margin-top:3px;display:flex;gap:7px;align-items:center;flex-wrap:wrap}
.u-row-stat{margin-left:auto;text-align:right;flex:0 0 auto}
.u-row-stat .n{font-size:14.5px;font-weight:700}
.u-row-stat .u{font-size:10.5px;color:var(--u-muted)}

/* ---------- responsive tables ----------
   app.css hides columns 4+ under 600px, which silently drops data. These
   tables turn into stacked cards instead, so nothing disappears on a phone. */
@media(max-width:600px){
  .u-table thead{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
  .u-table,.u-table tbody,.u-table tr,.u-table td{display:block;width:100%}
  .u-table tr{
    border:1px solid var(--u-line);border-radius:var(--u-r-sm);
    padding:10px 12px;margin-bottom:10px;background:#fff;
  }
  .u-table td{
    display:flex;align-items:center;gap:12px;padding:5px 0!important;border:0!important;
    font-size:13px;
  }
  .u-table td::before{
    content:attr(data-label);flex:0 0 40%;max-width:40%;
    font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--u-muted);
  }
  .u-table td:first-child{font-weight:650;font-size:14px}
  .u-table td[data-label=""]::before,.u-table td:not([data-label])::before{display:none}
  /* undo the old column-hiding hack for any table that opts in */
  .u-table td:nth-child(n+4):not(:last-child),
  .u-table th:nth-child(n+4):not(:last-child){display:flex!important}
}

/* ---------- section heading ---------- */
.u-h{font-size:12px;font-weight:750;letter-spacing:.1em;text-transform:uppercase;color:var(--u-muted);margin:4px 0 10px}

/* ---------- empty state ---------- */
.u-empty{padding:28px 18px;text-align:center;color:var(--u-muted)}
.u-empty .i{font-size:26px;opacity:.4;display:block;margin-bottom:9px}
.u-empty p{font-size:13px;margin:0 0 12px}

/* ---------- page scaffolding ---------- */
.u-page{display:flex;flex-direction:column;gap:14px}
.u-page-head{display:flex;align-items:flex-start;gap:12px;flex-wrap:wrap}
.u-page-head h1{font-size:19px;font-weight:750;letter-spacing:-.35px;margin:0}
.u-page-head p{font-size:12.5px;color:var(--u-muted);margin:2px 0 0}
.u-page-head .u-actions{margin-left:auto;display:flex;gap:8px;flex-wrap:wrap}
@media(max-width:520px){
  .u-page-head .u-actions{width:100%;margin-left:0}
  .u-page-head .u-actions .u-btn{flex:1}
}

/* ---------- two column split ---------- */
.u-split{display:grid;grid-template-columns:1fr;gap:14px}
@media(min-width:980px){.u-split{grid-template-columns:1.55fr 1fr;align-items:start}}

/* ---------- bottom tab bar (phones only) ---------- */
.u-tabbar{display:none}
@media(max-width:991px){
  .u-tabbar{
    display:grid;grid-template-columns:repeat(5,1fr);
    position:fixed;left:0;right:0;bottom:0;z-index:1040;
    background:#fff;border-top:1px solid var(--u-line);
    padding:6px 0 max(8px, env(safe-area-inset-bottom));
  }
  .u-tab{
    display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;
    font-size:10.5px;color:var(--u-muted);text-decoration:none;position:relative;min-height:var(--u-tap);
  }
  .u-tab i{font-size:17px;line-height:1}
  .u-tab.active{color:var(--u-teal);font-weight:700}
  .u-tab .u-tab-badge{
    position:absolute;top:0;right:26%;background:var(--u-signal);color:#fff;
    font-size:9px;font-weight:700;padding:0 5px;border-radius:20px;line-height:15px;
  }
  .u-fab{
    justify-self:center;width:44px;height:44px;border-radius:14px;background:var(--u-teal);
    color:#fff;display:grid;place-items:center;font-size:20px;margin-top:-14px;
    box-shadow:0 4px 12px rgba(14,92,87,.35);text-decoration:none;
  }
  /* keep content clear of the bar */
  body.has-tabbar{padding-bottom:74px}
}

/* ---------- profile strength ring ---------- */
.u-ring-wrap{display:flex;align-items:center;gap:14px}
.u-ring{position:relative;width:84px;height:84px;flex:0 0 84px}
.u-ring svg{transform:rotate(-90deg)}
.u-ring-num{position:absolute;inset:0;display:grid;place-items:center;font-size:19px;font-weight:700}
.u-todo{margin-top:12px;display:flex;flex-direction:column;gap:8px}
.u-todo-item{display:flex;align-items:center;gap:9px;font-size:12.5px;padding:9px 11px;background:var(--u-paper);border-radius:var(--u-r-sm);min-height:40px}
.u-todo-item .tick{width:15px;height:15px;border-radius:50%;border:1.5px solid #C4CFCC;flex:0 0 15px}
.u-todo-item.done{color:var(--u-muted)}
.u-todo-item.done .tick{background:var(--u-good);border-color:var(--u-good)}
.u-todo-go{margin-left:auto;font-size:11.5px;color:var(--u-teal);font-weight:700;text-decoration:none}

/* ---------- horizontal scroll rails (chips, filters) ---------- */
.u-rail{display:flex;gap:8px;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none;padding-bottom:2px}
.u-rail::-webkit-scrollbar{display:none}
.u-rail > *{flex:0 0 auto}

/* ---------- global mobile hygiene ---------- */
@media(max-width:600px){
  /* nothing should force a horizontal scrollbar */
  html,body{overflow-x:hidden}
  img,video,iframe,table{max-width:100%}
  /* iOS zooms any input under 16px on focus */
  input,select,textarea{font-size:16px!important}
  .u-card-body{padding:13px}
}

@media(prefers-reduced-motion:reduce){
  *{animation-duration:.001ms!important;transition-duration:.001ms!important}
}

/* ==========================================================================
   Global mobile fixes for pages not yet individually rebuilt.
   app.css hides every column from the 4th onwards under 600px, which does not
   make a table mobile-friendly — it deletes data the user came for. Restore
   the columns and let the table scroll sideways instead.
   ========================================================================== */
@media(max-width:600px){
  .table td:nth-child(n+4):not(:last-child),
  .table th:nth-child(n+4):not(:last-child){display:table-cell!important}

  /* Tables that have not been converted to .u-table scroll instead of hiding. */
  .table:not(.u-table){display:block;overflow-x:auto;-webkit-overflow-scrolling:touch;white-space:nowrap}
  .table:not(.u-table) td,.table:not(.u-table) th{white-space:nowrap}

  /* Common overflow culprits on legacy pages. */
  .container,.container-fluid{padding-left:14px;padding-right:14px}
  pre,code{white-space:pre-wrap;word-break:break-word}
  .btn-group{flex-wrap:wrap}
  /* Stop long unbroken strings (URLs, slugs) blowing out the layout. */
  td,th,p,li,dd,.card-body{overflow-wrap:anywhere}
}

/* Modal and dropdown panels must never exceed the viewport on a phone. */
@media(max-width:600px){
  .modal-dialog{margin:.5rem}
  .dropdown-menu{max-width:calc(100vw - 24px)}
}

/* ==========================================================================
   Touch targets on phones.
   Measured at 390px with a real browser: the header's mobile links, the
   Bootstrap .btn default (~38px), the listing tabs and the sector/tag chips
   all landed under the 40px a thumb reliably hits. These lift the controls
   without touching desktop, where a cursor makes 38px perfectly usable.
   ========================================================================== */
@media(max-width:991px){
  .btn,
  .gh-mob-link,
  .lp-tab,
  .hp-see-all,
  .footer-link{
    min-height:44px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
  }
  /* Links in a list still read as text, so keep them left-aligned. */
  .gh-mob-link,.footer-link{justify-content:flex-start}

  /* Chips are secondary controls — 38px is enough, but not 24px. */
  .hp-tag,
  .lc-sector,
  .chip{min-height:38px;display:inline-flex;align-items:center}

  /* Icon-only buttons need width as well as height. */
  .btn-icon,.gh-icon-btn,.dash-ico-btn,.adm-ico-btn{min-width:44px}

  /* Adjacent controls must not merge into one target. */
  .btn + .btn{margin-left:6px}
}

/* Body copy floor. Badges and eyebrow labels stay small on purpose; running
   text does not. */
@media(max-width:600px){
  p,li,dd,.lp-body,.hp-sub,.card-text{font-size:14px;line-height:1.55}
}

/* ==========================================================================
   Header overflow on phones.
   Measured at 390px: .gh-brand + .gh-cta-btn + .gh-login-btn + .gh-reg-btn +
   .gh-ham are all flex-shrink:0 with white-space:nowrap, so the row is 48px
   wider than the viewport and the hamburger sits off-screen — the menu is
   literally unreachable on a phone. The CTA and auth buttons already exist
   inside the mobile drawer, so drop them from the bar and let the menu win.
   ========================================================================== */
@media(max-width:600px){
  .gh-inner{padding:0 .75rem;gap:.4rem;min-width:0}
  .gh-actions{min-width:0;gap:.25rem}
  .gh-cta-btn,
  .gh-login-btn,
  .gh-reg-btn{display:none!important}
  .gh-ham{margin-left:auto;flex-shrink:0}
  .gh-brand{min-width:0}
  .gh-brand span,.gh-brand .gh-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
}
/* Small tablets keep the CTA but lose the secondary auth links. */
@media(min-width:601px) and (max-width:820px){
  .gh-login-btn,.gh-reg-btn{display:none!important}
}

/* Remaining sub-40px controls found in the 390px audit. */
@media(max-width:991px){
  .gh-ham,.gh-icon-btn,.gh-brand{min-height:44px}
  .gh-ham,.gh-icon-btn{min-width:44px;display:inline-flex;align-items:center;justify-content:center}
  .hp-tag,.lc-sector{min-height:40px;padding-left:12px;padding-right:12px}
  /* .lc-sector is a link, not a badge — it has to be readable as well as tappable. */
  .lc-sector{font-size:12.5px}
  footer a,.footer-link{min-height:44px;display:inline-flex;align-items:center}
}

/* ==========================================================================
   Product page.
   Bootstrap's g-5 gutter applies -1.5rem side margins, which pushed the row
   10px past the viewport at 390px. Tighten the gutter on phones and lift the
   quantity stepper to a usable size.
   ========================================================================== */
@media(max-width:600px){
  .row.g-5{--bs-gutter-x:1.25rem;--bs-gutter-y:1.25rem}
  .pp-qty-btn{min-width:44px;min-height:44px;display:inline-flex;align-items:center;justify-content:center}
  .text-mute[href],a.text-mute{min-height:44px;display:inline-flex;align-items:center}
}
