/* Shared control contract. Loaded after component styles so every surface,
   including dialogs and dynamically inserted loading messages, uses it. */
body :is(button, input, select, textarea, option, optgroup, dialog, [role="button"],
  [role="status"], .empty-state, .form-status, .portal-empty,
  .portal-presence-loading, .portal-inbox-count) {
  font-family: var(--font-sans);
  letter-spacing: normal;
}
input::file-selector-button { font: inherit; }
input::placeholder, textarea::placeholder { font-family: inherit; opacity: 1; }
input::-webkit-date-and-time-value { font-family: inherit; text-align: start; }

/* Keep custom file pickers keyboard-accessible while leaving the native input visually hidden. */
body .file-button { position: relative; }
body .file-button input[type="file"] {
  position: absolute;
  display: block;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
body .file-button:has(input:disabled) { opacity: .55; cursor: not-allowed; }

body :is(.primary, .primary-button, .secondary, .secondary-button, .outline,
  .budget-button, .file-button, .portal-link-button, .portal-inbox-new,
  .portal-form-actions button, .portal-composer button, .portal-claim-approval button) {
  min-height: 40px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

/* Secondary actions remain distinct from filled primary and approval buttons. */
body :is(.secondary, .secondary-button, .outline.dark, .budget-button,
  .portal-link-button, .portal-form-actions button) {
  border: 1px solid #b9c9e4;
  color: #1746c2;
  background: #fff;
  box-shadow: none;
}
body :is(.primary, .primary-button, .budget-button.primary,
  .portal-form-actions .primary, .file-button, .portal-inbox-new, .portal-composer button) {
  border: 1px solid #1746c2;
  color: #fff;
  background: #1746c2;
  box-shadow: 0 1px 2px rgba(14, 43, 105, .12);
}
body :is(.budget-button.share, .portal-claim-approval button) {
  border: 1px solid #087653;
  color: #fff;
  background: #087653;
}
body :is(.danger-outline, .link-button.danger) {
  border-color: #e4aaaa;
  color: #b42318;
}
body :is(.icon-close, .portal-icon-button, .portal-inbox-close, .portal-inbox-minimize, .budget-remove) {
  flex-shrink: 0;
  padding: 0;
  border: 1px solid #cbd5e3;
  color: #40516b;
  background: #f4f7fb;
  line-height: 1;
}
body :is(.dialog-actions, .portal-form-actions) { flex-wrap: wrap; gap: 10px; }
body .dialog-actions .outline { margin-left: 0; }

/* Only show hover treatment where hover exists; never animate disabled controls. */
@media (hover: hover) {
  body :is(button, [role="button"]):not(:disabled):not([aria-disabled="true"]):hover {
    filter: brightness(.96);
  }
  body :is(.secondary, .secondary-button, .outline.dark, .budget-button,
    .portal-link-button, .portal-form-actions button):not(:disabled):not([aria-disabled="true"]):hover {
    background: #edf3ff;
    border-color: #7e9fe2;
  }
  body :is(.primary, .primary-button, .budget-button.primary, .portal-form-actions .primary,
    .file-button, .portal-inbox-new, .portal-composer button):not(:disabled):not([aria-disabled="true"]):hover {
    background: #1039a6;
    border-color: #1039a6;
  }
  body :is(.budget-button.share, .portal-claim-approval button):not(:disabled):hover { background: #065d42; }
  body :is(.danger-outline, .link-button.danger):not(:disabled):hover { background: #fff0ee; }
}

body :is(button, a[href], input, select, textarea, summary, [role="button"]):focus-visible,
body :is(.file-button, .portal-attach-button):focus-within {
  outline: 3px solid #527fed;
  outline-offset: 3px;
}
body :is(button, input, select, textarea):disabled,
body [aria-disabled="true"] {
  opacity: .55;
  cursor: not-allowed;
  filter: none;
  transform: none;
  box-shadow: none;
}
body :is(button, [role="button"])[aria-busy="true"] { cursor: progress; }
body :is(button, input, select, textarea):disabled:hover,
body [aria-disabled="true"]:hover { filter: none; transform: none; }

/* 16px form text avoids iOS focus zoom without disabling pinch-to-zoom.
   Important is intentional: component rules otherwise shrink these fields. */
@media (max-width: 680px), (pointer: coarse) {
  body :is(input, select, textarea) {
    font-size: 16px !important;
    line-height: 1.4;
  }
  body :is(button, [role="button"], summary, input[type="button"], input[type="submit"],
    input[type="reset"], .file-button, .portal-attach-button, .portal-update-action) {
    min-width: 44px !important;
    min-height: 44px !important;
    touch-action: manipulation;
  }
  body input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]),
  body select, body textarea { min-height: 44px !important; }
  body label:has(input[type="checkbox"]), body label:has(input[type="radio"]) {
    min-height: 44px;
    min-width: 44px;
  }
  body input:is([type="checkbox"], [type="radio"]) {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    min-height: 20px;
    margin: 0;
    accent-color: #1746c2;
  }
  body :is(.dialog-actions, .portal-form-actions) > button { flex: 1 1 130px; }
  body .brand-refresh { flex-basis: 44px; }
  body .calendar-toolbar { gap: 8px; }
  body .portal-attachment-chip { grid-template-columns: 46px minmax(0, 1fr) 44px; }
  body .portal-thread-search { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  body :is(button, [role="button"], .file-button) { transition: none; }
}
