/* Shared presentation layer. Load after the route stylesheet on own UR pages. */
body.ur-glass {
  --glass-ink: #202631;
  --glass-muted: #5e6878;
  --glass-blue: #125dcc;
  --glass-blue-hover: #0a48a4;
  --glass-border: #dce2eb;
  --glass-surface: #fafdff;
  --glass-card: #fff;
  --glass-shadow: 0 6px 24px rgb(35 49 73 / .035), inset 0 1px 0 #fff;
  color-scheme: light;
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 90% 0%, rgb(214 229 250 / .55), transparent 35%),
    linear-gradient(160deg, #f5f6f9, #eff2f7);
  color: var(--glass-ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body.ur-glass *,
body.ur-glass *::before,
body.ur-glass *::after { box-sizing: border-box; }
body.ur-glass [hidden] { display: none !important; }
body.ur-glass .ur-shell {
  width: 100%;
  max-width: 1440px;
  min-width: 0;
  margin: 0 auto;
  padding: 24px 32px 64px;
  color: var(--glass-ink);
}
body.ur-glass .ur-shell > * { min-width: 0; }
body.ur-glass :is(h1, h2, h3, p, li, blockquote, dd) { overflow-wrap: anywhere; }
body.ur-glass :is(h1, h2, h3) {
  color: var(--glass-ink);
  font-weight: 600;
  letter-spacing: -.025em;
  line-height: 1.25;
}
body.ur-glass h1 { font-size: clamp(28px, 3vw, 38px); margin: 0 0 10px; }
body.ur-glass h2 { font-size: 21px; margin: 0 0 16px; }
body.ur-glass h3 { font-size: 18px; }
body.ur-glass a { color: var(--glass-blue); text-underline-offset: 4px; }
body.ur-glass :is(a, button, input, select, textarea, summary):focus-visible,
body.ur-glass [tabindex]:focus-visible {
  outline: 3px solid var(--glass-blue);
  outline-offset: 3px;
}

/* Navigation stays in document flow; every available destination can wrap. */
body.ur-glass .glass-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 12px 16px;
  margin-bottom: 28px;
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  background: var(--glass-surface);
  box-shadow: var(--glass-shadow);
}
body.ur-glass .glass-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--glass-ink);
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -.035em;
  text-decoration: none;
  white-space: nowrap;
}
body.ur-glass .glass-brand svg { width: 34px; height: 34px; flex-shrink: 0; }
body.ur-glass .glass-nav-links {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  padding: 4px;
  border: 1px solid rgb(166 184 216 / .12);
  border-radius: 18px;
  background: rgb(229 233 240 / .7);
}
body.ur-glass .glass-nav-links a,
body.ur-glass .glass-account {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 14px;
  color: var(--glass-muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  text-align: center;
  overflow-wrap: anywhere;
}
body.ur-glass .glass-nav-links a[aria-current="page"] {
  color: var(--glass-blue);
  background: #fff;
  box-shadow: 0 2px 8px rgb(38 58 100 / .09), inset 0 1px 0 #fff;
}
body.ur-glass .glass-account { gap: 8px; }
body.ur-glass .glass-page-header { margin: 0 0 24px; max-width: none; }
body.ur-glass .glass-page-header p { max-width: 850px; }
body.ur-glass :is(.glass-eyebrow, .dl-eyebrow, .cw-eyebrow, .cr-eyebrow, .client-eyebrow, .mail-eyebrow) {
  color: var(--glass-blue);
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .1em;
  text-transform: uppercase;
}
body.ur-glass :is(.dl-hint, .cw-hint, .cr-hint, .ur-hint, .client-help, .mail-help,
  .dl-result-meta, .glass-page-header > p:last-child, .cw-heading p:last-child,
  .client-heading p, .mail-heading p) { color: var(--glass-muted); }
body.ur-glass .cw-breadcrumb { margin: -12px 0 22px; color: var(--glass-muted); }

/* Opaque defaults keep the same hierarchy when backdrop blur is unsupported. */
body.ur-glass :is(.dl-panel, .cw-panel, .cw-actions, .cr-panel,
  .client-search-panel, .client-results-panel, .mail-panel, .ur-filters, .ur-table-wrap) {
  min-width: 0;
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  background: var(--glass-surface);
  box-shadow: var(--glass-shadow);
  padding: 24px;
}
body.ur-glass :is(.cr-card, .client-card, .mail-card) {
  min-width: 0;
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  background: var(--glass-card);
  box-shadow: 0 4px 16px rgb(40 59 108 / .035), inset 0 1px 0 #fff;
  padding: 24px;
}
body.ur-glass :is(.cw-note, .mail-body) {
  border-color: var(--glass-border);
  border-radius: 16px;
  background: #f0f4fb;
  color: var(--glass-muted);
}
body.ur-glass :is(.cw-chip, .cr-chip, .dl-chip, .ur-status, .client-status, .mail-state) {
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  padding: 6px 12px;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}
body.ur-glass :is(.cw-chip, .cr-chip, .dl-chip):not(.dl-chip-partial) {
  border-color: var(--glass-border);
  background: #eef3fb;
  color: var(--glass-muted);
}
body.ur-glass .cw-step {
  background: #eaf0ff;
  color: var(--glass-blue);
  border-color: #c7d6f5;
  border-radius: 12px;
}

body.ur-glass :is(button, input, select, textarea) { font: inherit; }
body.ur-glass :is(button, input, select, textarea, .ur-button) {
  min-height: 44px;
  max-width: 100%;
  border: 1px solid #bdcbe1;
  border-radius: 14px;
}
body.ur-glass :is(input, select, textarea) {
  width: 100%;
  min-width: 0;
  padding: 11px 14px;
  background: rgb(255 255 255 / .94);
  border-color: #8190a9;
  color: var(--glass-ink);
  box-shadow: inset 0 1px 2px rgb(28 45 78 / .025);
}
body.ur-glass textarea { min-height: 112px; resize: vertical; }
body.ur-glass input::placeholder { color: #63738b; opacity: 1; }
body.ur-glass input[type="file"] { padding: 7px; }
body.ur-glass input::file-selector-button {
  min-height: 44px;
  font: inherit;
  margin-right: 10px;
  padding: 8px 12px;
  border: 1px solid #bdcbe1;
  border-radius: 10px;
  background: #eef3fb;
  color: var(--glass-ink);
  cursor: pointer;
}
body.ur-glass :is(button, .ur-button) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  background: #fff;
  color: var(--glass-ink);
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  overflow-wrap: anywhere;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
}
body.ur-glass :is(.dl-primary, .cw-primary, .cr-primary, .client-primary, .mail-primary, .ur-button) {
  background: var(--glass-blue);
  border-color: var(--glass-blue);
  color: #fff;
  box-shadow: 0 4px 10px rgb(36 92 200 / .14), inset 0 1px 0 rgb(255 255 255 / .16);
}
body.ur-glass :is(button, input, select, textarea):disabled,
body.ur-glass fieldset:disabled :is(button, input, select, textarea) {
  cursor: not-allowed;
  opacity: .65;
  box-shadow: none;
}
body.ur-glass :is(input, select, textarea):disabled {
  color: var(--glass-muted);
  background: #eaf0f7;
}
body.ur-glass label { color: var(--glass-ink); font-size: 14px; font-weight: 600; }
body.ur-glass :is(input, select, textarea):enabled { border-color: #8190a9; }
body.ur-glass label :is(input, select, textarea) { font-size: 16px; }
/* Native details keep keyboard and expanded semantics, with named actions instead of arrows. */
body.ur-glass summary { color: var(--glass-ink); list-style: none; }
body.ur-glass summary::-webkit-details-marker { display: none; }
body.ur-glass summary::marker { content: ""; }
body.ur-glass .ur-disclosure {
  margin-top: 20px;
  border-top: 1px solid var(--glass-border);
}
body.ur-glass .ur-disclosure > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  padding: 12px 0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
}
body.ur-glass .ur-disclosure > summary > :first-child { min-width: 0; }
body.ur-glass :is(.ur-disclosure-open, .ur-disclosure-close) {
  flex-shrink: 0;
  color: var(--glass-blue);
  font-size: 13px;
}
body.ur-glass .ur-disclosure-close,
body.ur-glass .ur-disclosure[open] > summary > .ur-disclosure-open { display: none; }
body.ur-glass .ur-disclosure[open] > summary > .ur-disclosure-close { display: inline; }
body.ur-glass :is(.cw-grid, .cr-cards, .client-results, .mail-results) { gap: 20px; }
body.ur-glass :is(.cw-grid, .client-actions, .mail-actions, .dl-actions, .cr-actions) > * { min-width: 0; }
body.ur-glass .cw-grid > a.cw-secondary {
  display: flex;
  align-items: center;
  min-height: 64px;
  padding: 16px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  background: var(--glass-card);
  text-decoration: none;
  font-weight: 600;
}
body.ur-glass .cr-jump a {
  padding: 10px 16px;
  border-color: var(--glass-border);
  border-radius: 999px;
  background: var(--glass-card);
  text-decoration: none;
}

body.ur-glass .dl-tools {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: 20px;
  align-items: start;
  margin: 24px 0;
}
body.ur-glass .dl-tools > .dl-panel { margin: 0; }
body.ur-glass .dl-tools .dl-search { grid-template-columns: minmax(0, 1fr); }
body.ur-glass .dl-tools .dl-actions { gap: 10px; }
body.ur-glass .dl-layout { gap: 20px; margin-top: 20px; }
body.ur-glass .dl-layout > .dl-panel { margin-top: 0; }
body.ur-glass .dl-tools .dl-hint { font-size: 13px; line-height: 1.5; margin-block: 8px 12px; }
body.ur-glass #document-upload-status {
  padding: 0;
  margin-bottom: 0;
  border: 0;
  background: transparent;
  color: var(--glass-muted);
  font-size: 14px;
}
body.ur-glass .dl-quote { border-left-color: #aebfda; }
body.ur-glass .dl-original { font-weight: 600; }

/* Semantic warnings, errors and delivery states retain their separate colors. */
body.ur-glass :is(.dl-status, .cw-message, .cr-status) {
  border-left-color: #5879ba;
  background: #e9f0fb;
  color: #294874;
  border-radius: 14px;
}
body.ur-glass :is(.dl-error, .dl-field-error, .cw-error, .cr-error, .client-error, .mail-error, #registry-error) {
  border: 1px solid #d59aa4;
  border-left: 4px solid #b72c4c;
  border-radius: 14px;
  padding: 16px;
  background: #fff0f3;
  color: #851b36;
}
body.ur-glass :is(.cw-field-error, [aria-invalid="true"]) { border-color: #b72c4c; }
body.ur-glass .cw-field-error { color: #9c2340; }
body.ur-glass :is(.dl-coverage-partial, .client-stale, .mail-note) {
  border: 1px solid #d4b76b;
  border-radius: 14px;
  background: #fff5da;
  color: #704c0f;
  padding: 14px 16px;
}
body.ur-glass .dl-chip-partial { background: #fff5da; color: #704c0f; border-color: #d4b76b; }
body.ur-glass mark { background: #ffeaa7; color: #473511; border-radius: 3px; }

/* Wide business tables scroll within their own surface, never at body level. */
body.ur-glass .ur-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin: 24px 0; }
body.ur-glass .ur-filter-actions { flex-wrap: wrap; }
body.ur-glass .ur-table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; padding: 0 20px 8px; }
body.ur-glass .ur-registry table { min-width: 980px; width: 100%; font-size: 14px; border-collapse: collapse; }
body.ur-glass .ur-registry caption { padding: 20px 0; color: var(--glass-muted); }
body.ur-glass .ur-registry th {
  background: #edf2fb;
  color: #43546f;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .015em;
}
body.ur-glass .ur-registry :is(th, td) { padding: 16px 12px; border-bottom-color: #dce4f1; }
body.ur-glass .ur-registry tbody tr:last-child td { border-bottom: 0; }
body.ur-glass .ur-registry td > a { color: var(--glass-blue); font-weight: 600; }

/* Modal content is nearly opaque; original PDFs and iframe content are untouched. */
body.ur-glass dialog,
body.ur-glass :is(#registry-basis, #client-detail, #mail-detail) {
  width: min(850px, calc(100% - 32px));
  max-width: 850px;
  max-height: calc(100dvh - 48px);
  overflow: auto;
  padding: 28px;
  border: 1px solid #d1dced;
  border-radius: 24px;
  background: #fcfdff;
  color: var(--glass-ink);
  box-shadow: 0 24px 80px rgb(19 36 72 / .24), inset 0 1px 0 #fff;
}
body.ur-glass dialog::backdrop { background: rgb(24 37 65 / .38); }
body.ur-glass :is(.client-dialog-heading, .mail-dialog-heading) { flex-wrap: wrap; }
body.ur-glass .glass-skip { position: absolute; top: -100px; left: 16px; padding: 12px; }
body.ur-glass .glass-skip:focus { top: 8px; }
body.ur-glass :is(#document-navigation-dialog, #contract-confirm-dialog, #review-confirm-dialog) {
  max-width: 520px;
}
body.ur-glass :is(.glass-skip, .dl-skip, .cw-skip, .cr-skip, .client-skip, .mail-skip) {
  border-radius: 12px;
  color: var(--glass-blue);
  background: #fff;
  z-index: 20;
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  body.ur-glass { --glass-surface: rgb(255 255 255 / .76); --glass-card: rgb(255 255 255 / .85); }
  body.ur-glass :is(.glass-nav, .dl-panel, .cw-panel, .cw-actions, .cr-panel,
    .client-search-panel, .client-results-panel, .mail-panel, .ur-filters) {
    -webkit-backdrop-filter: blur(20px) saturate(125%);
    backdrop-filter: blur(20px) saturate(125%);
  }
}
@media (hover: hover) {
  body.ur-glass .glass-nav-links a:not([aria-current="page"]):hover,
  body.ur-glass .glass-account:hover { color: var(--glass-ink); background: #fff; }
  body.ur-glass button:not(:disabled):hover { background: #eef3fc; border-color: #9cb2d6; }
  body.ur-glass :is(.dl-primary, .cw-primary, .cr-primary, .client-primary, .mail-primary):not(:disabled):hover,
  body.ur-glass .ur-button:hover { color: #fff; background: var(--glass-blue-hover); border-color: var(--glass-blue-hover); }
  body.ur-glass .cw-grid > a.cw-secondary:hover { background: #eff4ff; border-color: #aebfda; }
  body.ur-glass .ur-registry tbody tr:hover { background: rgb(235 241 255 / .65); }
}
@media (max-width: 1100px) {
  body.ur-glass .glass-nav { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  body.ur-glass .glass-nav-links { grid-column: 1 / -1; grid-row: 2; }
  body.ur-glass .glass-account { grid-column: 2; grid-row: 1; }
}
@media (max-width: 900px) {
  body.ur-glass .ur-shell { padding: 20px 24px 48px; }
  body.ur-glass .dl-tools { grid-template-columns: minmax(0, 1fr); }
  body.ur-glass .ur-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  body.ur-glass .ur-shell { padding: 16px 16px 40px; }
  body.ur-glass .glass-nav { padding: 10px; gap: 10px; margin-bottom: 28px; border-radius: 22px; }
  body.ur-glass .glass-brand { font-size: 18px; padding-left: 4px; }
  body.ur-glass .glass-nav-links { justify-content: stretch; border-radius: 18px; }
  body.ur-glass .glass-nav-links a { flex: 1 1 135px; padding: 10px 12px; border-radius: 14px; }
  body.ur-glass .glass-account { padding: 10px 14px; }
  body.ur-glass .glass-page-header { margin-bottom: 24px; }
  body.ur-glass h1 { font-size: 30px; }
  body.ur-glass h2 { font-size: 20px; }
  body.ur-glass :is(.dl-panel, .cw-panel, .cw-actions, .cr-panel, .cr-card, .client-card,
    .mail-card, .client-search-panel, .client-results-panel, .mail-panel, .ur-filters) { padding: 20px; }
  body.ur-glass :is(.ur-filters, .dl-layout, .cw-grid, .cr-cards, .client-results, .mail-results) {
    grid-template-columns: minmax(0, 1fr);
  }
  body.ur-glass .dl-search { grid-template-columns: minmax(0, 1fr); }
  body.ur-glass .dl-tools, body.ur-glass .dl-layout { gap: 20px; }
  body.ur-glass .ur-table-wrap { padding-inline: 12px; border-radius: 20px; }
  body.ur-glass :is(.client-actions, .mail-actions, .dl-actions) > button { flex: 1 1 130px; }
  body.ur-glass .mail-details { grid-template-columns: minmax(0, 1fr); }
  body.ur-glass dialog,
  body.ur-glass :is(#registry-basis, #client-detail, #mail-detail) {
    width: calc(100% - 24px);
    max-height: calc(100dvh - 24px);
    padding: 20px;
    border-radius: 22px;
  }
}
@media (prefers-reduced-motion: reduce) {
  body.ur-glass *, body.ur-glass *::before, body.ur-glass *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
@media (prefers-reduced-transparency: reduce) {
  body.ur-glass { --glass-surface: #fafdff; --glass-card: #fff; background: #f0f4fb; }
  body.ur-glass :is(.glass-nav, .dl-panel, .cw-panel, .cw-actions, .cr-panel,
    .client-search-panel, .client-results-panel, .mail-panel, .ur-filters) {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  body.ur-glass .glass-nav-links { background: #e7edf8; }
}
