/* Connect the existing staff controllers and their scoped components to the same palette. */
:root {
  --canvas: var(--ve-canvas);
  --surface: var(--ve-surface);
  --surface-2: var(--ve-surface-subtle);
  --surface-3: var(--ve-canvas);
  --line: var(--ve-line);
  --line-strong: var(--ve-line-strong);
  --ink: var(--ve-ink);
  --ink-2: var(--ve-ink);
  --ink-3: var(--ve-muted);
  --ink-4: var(--ve-muted);
  --ink-5: var(--ve-muted);
  --navy: var(--ve-brand);
  --navy-2: var(--ve-brand);
  --brand: var(--ve-link);
  --brand-2: var(--ve-link-soft);
  --sans: var(--ve-font);
  --r: var(--ve-radius-control);
  --r-md: var(--ve-radius);
  --sh-1: var(--ve-shadow);
  --sh-3: var(--ve-shadow-overlay);
  --sidebar-bg: var(--ve-surface);
  --sidebar-line: var(--ve-line);
  --nav-active-bg: var(--ve-link-soft);
  --nav-active-fg: var(--ve-link);
  --nav-active-icon: var(--ve-link);
  --nav-hover-bg: var(--ve-canvas);
  --cd-canvas: var(--ve-canvas);
  --cd-surface: var(--ve-surface);
  --cd-surface-subtle: var(--ve-surface-subtle);
  --cd-surface-sunken: var(--ve-canvas);
  --cd-ink-strong: var(--ve-ink);
  --cd-ink-heading: var(--ve-ink);
  --cd-ink-muted: var(--ve-muted);
  --cd-ink-quiet: var(--ve-muted);
  --cd-primary: var(--ve-link);
  --cd-primary-dark: var(--ve-link);
  --cd-primary-surface: var(--ve-link-soft);
  --cd-border: var(--ve-line);
  --cd-border-quiet: var(--ve-line);
  --cd-border-strong: var(--ve-line-strong);
  --cd-navy: var(--ve-brand);
  --cd-font-sans: var(--ve-font);
  --cd-text-page: var(--ve-text-page);
  --cd-text-section: var(--ve-text-section);
  --cd-text-body: var(--ve-text-body);
  --cd-text-control: var(--ve-text-small);
  --cd-text-small: var(--ve-text-small);
  --cd-leading-body: var(--ve-leading);
  --cd-control-h: var(--ve-control);
  --cd-gutter: var(--ve-gutter);
  --cd-radius-md: var(--ve-radius);
  --cd-radius-lg: var(--ve-radius);
}

body {
  font-family: var(--ve-font);
  color: var(--ve-ink);
  background: var(--ve-canvas);
  font-size: var(--ve-text-small);
  line-height: var(--ve-leading);
}

:is(#appShell, #drawer, #loginWrap, dialog, .pick, .pal)
  :is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: var(--ve-focus);
  outline-offset: 2px;
}

/* Navigation and utility disclosures share the page tabs' visible current state. */
.sidebar .brand-mark {
  background: var(--ve-brand);
}

.sidebar .nav-item {
  min-height: var(--ve-touch);
  color: var(--ve-ink);
  font-size: var(--ve-text-small);
  font-weight: 600;
}

.sidebar .nav-item.active,
.sidebar [aria-current="page"],
.sidebar .ve-nav-more[open] > summary {
  color: var(--ve-link);
  background: var(--ve-link-soft);
}

.ve-nav-more > summary,
.ve-utility-menu > summary {
  list-style: none;
  cursor: pointer;
}

.ve-nav-more > summary::-webkit-details-marker,
.ve-utility-menu > summary::-webkit-details-marker {
  display: none;
}

.ve-nav-more > summary {
  display: flex;
  align-items: center;
  gap: var(--ve-space-2);
  min-height: var(--ve-touch);
  padding-inline: var(--ve-space-3);
  border-radius: var(--ve-radius-control);
  font-weight: 650;
}

.ve-nav-more > summary::after,
.ve-utility-menu > summary::after {
  content: '';
  inline-size: 7px;
  block-size: 7px;
  margin-inline-start: auto;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: translateY(-2px) rotate(45deg);
}

.ve-nav-more[open] > summary::after,
.ve-utility-menu[open] > summary::after {
  transform: translateY(2px) rotate(225deg);
}

.ve-nav-more > .nav-group {
  margin: var(--ve-space-1) 0 0 var(--ve-space-2);
  border-inline-start: 1px solid var(--ve-line);
  padding-inline-start: var(--ve-space-1);
}

.ve-section-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ve-space-1);
  margin-block-end: var(--ve-space-4);
  padding: var(--ve-space-1);
  border: 1px solid var(--ve-line);
  border-radius: var(--ve-radius);
  background: var(--ve-surface);
}

.ve-section-nav[hidden] { display: none; }

.ve-section-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--ve-control);
  padding-inline: var(--ve-space-3);
  border-radius: var(--ve-radius-control);
  color: var(--ve-muted);
  font-weight: 650;
  text-decoration: none;
}

.ve-section-nav a:hover,
.ve-section-nav a[aria-current="page"] {
  color: var(--ve-link);
  background: var(--ve-link-soft);
}

.ve-utility-menu {
  position: relative;
  flex: 0 0 auto;
}

.ve-utility-menu > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--ve-space-2);
  min-height: var(--ve-control);
  padding-inline: var(--ve-space-3);
  border: 1px solid var(--ve-line);
  border-radius: var(--ve-radius-control);
  background: var(--ve-surface);
  font-weight: 650;
}

.ve-utility-actions {
  position: absolute;
  z-index: var(--cd-layer-dropdown);
  inset: calc(100% + var(--ve-space-2)) 0 auto auto;
  display: grid;
  gap: var(--ve-space-1);
  min-inline-size: 176px;
  max-inline-size: min(22rem, 85vw);
  max-block-size: min(70dvh, 26rem);
  overflow: auto;
  padding: var(--ve-space-1);
  border: 1px solid var(--ve-line);
  border-radius: var(--ve-radius);
  background: var(--ve-surface);
  box-shadow: var(--ve-shadow-overlay);
}

.ve-utility-menu:not([open]) > .ve-utility-actions { display: none; }
.ve-utility-actions :is(button, a) { min-block-size: var(--ve-control); justify-content: flex-start; text-align: start; }
.ve-utility-actions > :is(button, a), .ve-utility-actions > [data-caseaid-slot] > button { inline-size: 100%; }
.ve-utility-actions .ve-caseaid-signout:not([hidden]) { display: inline-flex; }
.ve-caseaid-actions .ve-utility-actions [data-caseaid-slot="refresh"] { display: block; }

.ve-mobile-create, .ci-fab:not(.has-ring) { display: none; }
.ve-caseaid-header .ve-caseaid-time:not(:has(.ve-time-running:not([hidden]))) { display: none; }
.ve-caseaid-header > .ve-time-tracker:not(.ve-time-running) { display: none; }
.ve-caseaid-header :is(.ca-feedback-launch, .ca-search-launch, .tb-btn) { min-block-size: var(--ve-control); }

/* The page heading is consistent even on modules with their own controller. */
.main > .content {
  padding-inline: var(--ve-gutter);
  min-inline-size: 0;
}

.content .view {
  min-inline-size: 0;
  max-inline-size: 96rem;
  margin-inline: auto;
}

.content .view :is(.page-head, .ve-casework-head, .io-header, .vcs-header,
  .vco > .vco-head, .lc-hero, .growth-header, .ve-provider-hero, .ve-fee-head,
  .draft-workspace > header, .vfe > header) {
  gap: var(--ve-space-3);
  flex-wrap: wrap;
  align-items: flex-start;
  margin-block: 0 var(--ve-space-4);
  padding: 0;
  border: 0;
  background: transparent;
}

.content .view :is(.page-head, .ve-casework-head, .io-header, .vcs-header,
  .vco > .vco-head, .lc-hero, .growth-header, .ve-provider-hero, .ve-fee-head,
  .draft-workspace > header, .vfe > header) h1 {
  margin: 0 0 var(--ve-space-1);
  color: var(--ve-ink);
  font-size: var(--ve-text-page);
  font-weight: 750;
  line-height: 1.16;
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}

.page-head .ph-txt { min-inline-size: min(14rem, 100%); }

.content .view :is(.page-sub, .ve-casework-head p, .io-header p, .vcs-header p,
  .vco > .vco-head p, .lc-hero p, .growth-header p, .ve-provider-hero p, .ve-fee-head p,
  .draft-workspace > header p, .vfe > header p) {
  margin-block: 0;
  color: var(--ve-muted);
  font-size: var(--ve-text-body);
  font-weight: 450;
  line-height: var(--ve-leading);
}

#v-contacts:has(.ve-ca-contacts-hero) {
  --ve-ca-gutter: 0px;
  margin: 0 auto;
}

#v-contacts .ve-ca-contacts-hero {
  padding: 0;
  border: 0;
  background: transparent;
}

.content :is(.card, .toolbar, .kpi, .ve-casework-panel, .io-panel, .vcs-metric,
  .vco-calendar, .vco-booking, .lc-directory, .lc-panel, .lc-case-heading,
  .growth-filter, .growth-kpi, .growth-card, .ve-provider-card, .ve-provider-table,
  .ve-provider-form, .ve-fee-card, .ve-fee-buckets article, .draft-sidebar,
  .draft-record, .vfe-panel),
.drawer :is(.card, .toolbar, .kpi) {
  min-inline-size: 0;
  border-color: var(--ve-line);
  border-radius: var(--ve-radius);
  background-color: var(--ve-surface);
  box-shadow: var(--ve-shadow);
}

.content .card-head,
.drawer .card-head {
  min-inline-size: 0;
  align-items: baseline;
  flex-wrap: wrap;
  padding: var(--ve-space-3) var(--ve-space-4);
  border-color: var(--ve-line);
}

.content .card-head h3,
.drawer .card-head h3,
.content .card-t {
  color: var(--ve-ink);
  font-size: var(--ve-text-body);
  font-weight: 700;
}

.content :is(.vcs-panel h2, .draft-inventory h2, .growth-funnel-header h2, .ve-provider-hero + section h2,
  .vfe-panel h2, .vco-calendar > .vco-head h2, .ve-fee-card h2) {
  font-size: var(--ve-text-section);
  line-height: 1.25;
}

.content :is(.kpi-val, .growth-kpi strong, .ve-fee-buckets strong) {
  font-size: var(--ve-text-page);
  font-weight: 750;
  letter-spacing: -.025em;
}

.content :is(.kpi-lbl, .kpi-foot, .hint, .result-line, .t-sub, .empty-txt),
.drawer :is(.hint, .t-sub, .empty-txt) {
  color: var(--ve-muted);
  font-size: var(--ve-text-small);
  font-weight: 500;
  line-height: 1.45;
}

.content .kpi-lbl { text-transform: none; letter-spacing: 0; }
.content .kpi::before { background: var(--ve-link); }
.content :is(.empty, .ql-empty) { padding: var(--ve-space-6) var(--ve-space-4); }
.content .empty-ico { background: var(--ve-link-soft); color: var(--ve-link); }
.content :is(.ph-actions, .card-foot, .tb-row, .chips), .drawer .ph-actions { min-inline-size: 0; flex-wrap: wrap; }

.content :is(.btn, .sel, .f-search input, .io-filter input, .io-filter select,
  .growth-filter input, .set-field input, .set-field select),
.drawer :is(.btn, .sel, input:not([type="checkbox"], [type="radio"], [type="hidden"])) {
  max-inline-size: 100%;
  min-block-size: var(--ve-control);
  border-radius: var(--ve-radius-control);
  font-size: var(--ve-text-small);
}

.content :is(.fgroup label, .ve-ca-contacts-toolbar .fgroup label),
.drawer .dl dt {
  color: var(--ve-muted);
  font-size: var(--ve-text-small);
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
}

.content :is(.btn-primary, .btn-primary:hover),
.drawer :is(.btn-primary, .btn-primary:hover) {
  background: var(--ve-brand);
  border-color: var(--ve-brand);
  color: var(--ve-surface);
  box-shadow: none;
}

.content .btn-primary:hover,
.drawer .btn-primary:hover { background: var(--ve-link); }

.content .btn-reset { min-block-size: var(--ve-control); }
.content .chip { min-block-size: 32px; height: auto; }
.content :is(.tbl-wrap, .growth-table-wrap), .drawer .tbl-wrap { max-inline-size: 100%; }
.content table.tbl thead th, .drawer table.tbl thead th { font-size: 12px; letter-spacing: .02em; }
.content table.tbl tbody td, .drawer table.tbl tbody td { font-size: var(--ve-text-small); }
.content :is(.t-primary, .t-sub), .drawer :is(.t-primary, .t-sub) { overflow-wrap: anywhere; }

/* Full records need room for readable navigation and related panels. */
#drawer.ve-record-workspace { width: min(78rem, calc(100vw - 2 * var(--ve-gutter))); max-width: 100%; }
#drawer.ve-record-workspace[data-record-type="contact"] { width: 100%; }
#drawer .dr-head { min-inline-size: 0; }
#drawer .dr-top h2 { font-size: var(--ve-text-section); overflow-wrap: anywhere; }
#drawer :is(.dr-top, .dr-strip, .dr-body, .dr-tabs) { min-inline-size: 0; }
#drawer .dr-strip-link { white-space: normal; overflow-wrap: anywhere; }
#drawer .dr-tabs { flex-wrap: wrap; gap: 0 var(--ve-space-1); }
#drawer .dr-tab { min-block-size: var(--ve-control); padding-inline: var(--ve-space-3); font-size: var(--ve-text-small); }
#drawer .dr-close { min-block-size: var(--ve-control); min-inline-size: var(--ve-control); }
#drawer .dr-body { overscroll-behavior: contain; }
#drawer .dl dd { min-inline-size: 0; overflow-wrap: anywhere; }
.ve-ca-profile-header { flex-wrap: wrap; }

@media (max-width: 1200px) {
  .topbar.ve-caseaid-header:has(.ve-caseaid-time > :not([hidden]), > .ve-time-tracker:not([hidden])):not(:has(.ve-time-running:not([hidden]))) {
    display: flex;
  }
}

@media (max-width: 900px) {
  .sidebar .ve-daily-mobile { display: none; }
  .mobile-bar .mbar-item { min-block-size: var(--ve-touch); }
  .ve-caseaid-header .menu-btn { display: none; }
  .ve-caseaid-header .ve-mobile-create {
    display: inline-flex;
    grid-area: 1 / 1;
    justify-self: start;
    min-block-size: var(--ve-touch);
    padding-inline: var(--ve-space-3);
    font-size: var(--ve-text-small);
  }
  .ve-caseaid-header .ve-utility-menu > summary { min-block-size: var(--ve-touch); }
  #drawer.ve-record-workspace { inset: 0; width: 100%; }
  #drawer.ve-record-workspace[data-record-type="contact"] { inset-block-start: 0; }
  body:has(#drawer.on.ve-record-workspace) #scrim { top: 0; }
  .content :is(.g-3, .g-4, .g-6):has(> .kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .ve-caseaid-header :is(.ca-feedback-launch, .ca-search-launch, .tb-btn) { min-inline-size: var(--ve-touch); }
  .ve-caseaid-header .ve-caseaid-actions { gap: var(--ve-space-1); }
  .ve-caseaid-header :is(.ve-mobile-create, .ve-utility-menu > summary) { padding-inline: var(--ve-space-2); }
  .content .view :is(.page-head, .ve-casework-head, .io-header, .vcs-header, .vco > .vco-head, .growth-header) {
    flex-direction: column;
  }
  .content .view .ph-txt { min-inline-size: 0; }
  .content .toolbar .f-search { min-inline-size: min(12rem, 100%); max-inline-size: none; }
  .content :is(.g-3, .g-4, .g-6):has(> .kpi) { grid-template-columns: minmax(0, 1fr); }
  .content :is(.chip, .io-queues button, .growth-tabs .btn) { min-block-size: var(--ve-touch); }
  .content .tbl-wrap :is(th, td), .drawer .tbl-wrap :is(th, td) { white-space: normal; }
  #drawer.ve-record-workspace { display: block; overflow-y: auto; }
  #drawer.ve-record-workspace .dr-body { overflow-y: visible; }
  #drawer .dr-head { padding: var(--ve-space-3) var(--ve-gutter); }
  #drawer .dr-body { padding-inline: var(--ve-gutter); }
  #drawer .dr-body :is(.g-2, .g-3, .g-4, .g-2-1, .g-1-2, .g-3-2, .ve-ca-profile-grid) {
    grid-template-columns: minmax(0, 1fr);
  }
  #drawer .dr-tabs { margin-block-end: 0; }
  #drawer .dr-tab { padding-inline: var(--ve-space-2); }
}

@media (prefers-reduced-motion: reduce) {
  .view, .drawer { animation: none; transition: none; }
}

#drawer .ve-contact-comms .ve-contact-timeline-day { margin-block-start: var(--ve-space-3, 12px); }
#drawer .ve-contact-comms .ve-contact-timeline-card { grid-template-columns: auto minmax(0, 1fr); }
#drawer .ve-contact-comms .ph-actions { gap: 6px; margin-block-start: 6px; }
#drawer .ve-contact-comms :is(.linkish, .btn-reset) {
  cursor: pointer; border: 1px solid #cad7e7; border-radius: 6px; padding: 6px 10px;
  background: #fff; color: #173a63; font: inherit; font-size: 13px; font-weight: 600;
}
#drawer .ve-contact-comms :is(.linkish, .btn-reset):hover { border-color: #83a0c2; background: #edf4fc; }
#drawer .ve-contact-comms :is(.linkish, .btn-reset):focus-visible { outline: 2px solid #245dae; outline-offset: 2px; }
@media (max-width: 620px) {
  #drawer[data-record-type="contact"]:has(.ve-ca-profile-header) .dr-tab { min-height: 44px; padding: 6px 8px; }
  #drawer .ve-contact-comms :is(.linkish, .btn-reset) { min-height: 40px; }
}
