/* BAVORA UI Excellence 1.0 — scoped refinements only.
 * Existing CSS tokens, role/tariff gates and tenant branding remain authoritative.
 */

/* Calendar events are native buttons, not un-focusable clickable DIVs. */
#page-content .cal-event:is(button) {
  appearance: none;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 28px;
  border: 0;
  font: inherit;
  font-size: .6875rem;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}
#page-content .cal-event:is(button):focus-visible {
  outline: 3px solid var(--success, #3d6b4f);
  outline-offset: 2px;
  position: relative;
  z-index: 2;
}
#page-content .cal-event:is(button):hover { filter: brightness(1.14); }
@media (pointer: coarse) {
  #page-content .cal-event:is(button) { min-height: 36px; }
}

/* Keep existing BAVORA component language, increase actual tap targets. */
#view-app .sidebar .nav-link { min-height: 44px; box-sizing: border-box; }
#page-content .crm-dashboard__calendar-link { min-height: 44px; }
#page-content .settings-nav .tab.settings-nav__item {
  min-height: 44px;
  box-sizing: border-box;
}

/* Strong keyboard focus without altering branding or custom tenant palettes. */
#view-app .sidebar .nav-link:focus-visible,
#page-content .settings-nav .tab.settings-nav__item:focus-visible {
  outline: 3px solid var(--success, #3d6b4f);
  outline-offset: -3px;
}
#view-app .sidebar .nav-link:focus-visible {
  outline-color: var(--bg, #faf8f5);
  background: rgba(255,255,255,.12);
  color: var(--bg, #faf8f5);
}
@media (prefers-reduced-motion: reduce) {
  #page-content .cal-event:is(button) { transition: none; }
}
/* BAVORA UI Excellence 1.1 — CRM record lists: discoverability and focus.
 * All styles are scoped; business/tenant branding remains unchanged.
 */
#page-content .crm-records-table-wrap {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
#page-content .crm-records-table-wrap:focus-visible {
  outline: 3px solid var(--success, #3d6b4f);
  outline-offset: -3px;
}
#page-content .crm-records-table-wrap > .crm-records-table {
  width: 100%;
  min-width: 740px;
}
#page-content .crm-records-table-wrap :is(.crm-record-link, .client-row-link) {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: var(--ink, #1a1a1a);
  font-weight: 650;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}
#page-content .crm-records-table-wrap :is(.crm-record-link, .client-row-link):hover {
  color: var(--success, #3d6b4f);
  text-decoration-color: currentColor;
}
#page-content .crm-records-table-wrap :is(.crm-record-link, .client-row-link):focus-visible {
  outline: 3px solid var(--success, #3d6b4f);
  outline-offset: 2px;
  text-decoration-color: currentColor;
}
@media (max-width: 780px) {
  #page-content .crm-records-table-wrap :is(.crm-record-link, .client-row-link) {
    min-height: 44px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #page-content .crm-records-table-wrap :is(.crm-record-link, .client-row-link) { transition: none; }
}

/* UI Excellence 1.2: practical design polish for navigation, forms and hero CTAs.
 * Scoped to CRM surfaces; preserve tenant themes and the official Studio header.
 */
#view-app .sidebar .nav-link > svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#view-app .sidebar .nav-link[aria-current="page"] {
  font-weight: 650;
}
#view-app .topbar #menu-toggle:focus-visible {
  outline: 3px solid var(--success, #3d6b4f);
  outline-offset: 2px;
}
/* Keep both headline actions precisely aligned, even if labels differ by industry. */
#page-content .crm-dashboard .crm-dashboard__head-side > :is(.crm-dashboard__primary-action, .crm-dashboard__calendar-link) {
  box-sizing: border-box;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-width: 190px;
  min-height: 44px;
  padding: 9px 13px;
  line-height: 1.35;
  text-align: center;
  white-space: normal;
}
@media (max-width: 640px) {
  #page-content .crm-dashboard .crm-dashboard__head-side {
    width: 100%;
    align-items: stretch;
  }
  #page-content .crm-dashboard .crm-dashboard__head-side > :is(.crm-dashboard__primary-action, .crm-dashboard__calendar-link) {
    min-width: 0;
  }
}
/* Focus and label clarity within CRM dialogs; no global tenant-style override. */
#modal-container .modal .field > label {
  font-size: max(.75rem, var(--eyebrow-size));
  letter-spacing: .07em;
}
#modal-container .modal .field:focus-within > label { color: var(--ink); }
#modal-container .modal :is(.input, .select, .textarea):focus-visible {
  outline: 2px solid var(--success, #3d6b4f);
  outline-offset: 2px;
  border-color: var(--success, #3d6b4f);
}
#modal-container .modal .modal-foot .btn { min-height: 44px; }
@media (max-width: 640px) {
  #modal-container .modal .modal-foot .btn { flex: 1 1 140px; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #view-app .sidebar .nav-link, #modal-container .modal :is(.input, .select, .textarea) { transition: none; }
}

/* BAVORA UI Excellence 1.3: Scoped responsive filters and readable KPI cards. */
#page-content .crm-list-filters { display:flex; flex-wrap:wrap; align-items:stretch; gap:12px; min-width:0; }
#page-content .crm-list-filters > :is(.input,.select) { flex:1 1 200px; min-width:0; max-width:320px; }
#page-content .crm-dashboard__kpis .kpi-value { overflow-wrap:anywhere; line-height:1.15; }
#page-content .crm-dashboard__grid .section-head a { display:inline-flex; align-items:center; min-height:44px; }
@media(max-width:640px) {
  #page-content .crm-list-filters > :is(.input,.select) { flex:1 1 100%; width:100%; max-width:none!important; }
}
@media(max-width:390px) {
  #page-content .crm-dashboard .kpi-grid.crm-dashboard__kpis { grid-template-columns:minmax(0,1fr)!important; }
  #page-content .crm-dashboard .crm-dashboard__kpis > .kpi {
    grid-template-columns:40px minmax(0,1fr); gap:0 12px; min-height:108px; align-items:center;
  }
  #page-content .crm-dashboard .crm-dashboard__kpi-icon { grid-column:1; grid-row:1; }
  #page-content .crm-dashboard .crm-dashboard__kpi-copy { grid-column:2; grid-row:1; min-width:0; }
}
@media(prefers-reduced-motion:reduce) {
  #page-content .crm-list-filters > :is(.input,.select) { transition:none; }
}
