.jibe-form {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  margin: 0 0 1.5rem;
  padding: 0;
  overflow: hidden;
}

.jibe-form__header {
  align-items: center;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(79, 70, 229, 0.8));
  color: #fff;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  padding: 1.25rem 1.75rem;
}

.jibe-form__title {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.jibe-form__actions {
  display: flex;
  gap: 0.75rem;
  white-space: nowrap;
}

.jibe-form__edit-link {
  color: #e0e7ff;
  font-size: 0.9rem;
  text-decoration: none;
}

.jibe-form__edit-link:hover {
  color: #fff;
}

.jibe-form__sections {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0;
}

.jibe-form__section {
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.05);
  border-radius: 10px;
  padding: 0.85rem 1.25rem;
}

.jibe-form__section + .jibe-form__section {
  margin-top: 1.25rem;
}
.jibe-form__sections > .jibe-form__section + .jibe-form__section {
  margin-top: 0;
}

.jibe-related-entity {
  margin-top: 1.25rem;
}

.jibe-form__section--width-100 {
  width: 100%;
}

.jibe-form__section-header {
  margin: 0.1rem 0 0.3rem;
}

.jibe-form__section-title {
  color: #0f172a;
  font-size: 1.05rem;
  font-weight: 600;
}

.jibe-form__section-description {
  color: #475569;
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* ===== Color2 field (palette picker) ===== */
.jibe-color2 {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.jibe-color2__swatch {
  width: 1em;
  height: 1em;
  border-radius: 2px;
  border: 1px solid rgba(15, 23, 42, 0.25);
  box-sizing: border-box;
  display: inline-block;
  cursor: pointer;
}

.jibe-color2-popover {
  position: absolute;
  display: none;
  z-index: 2100;
}
.jibe-color2-popover.is-open {
  display: block;
}
.jibe-color2-popover__panel {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 18px 42px rgba(9, 12, 18, 0.25);
}
.jibe-color2-popover__grid {
  display: grid;
  gap: 0;
}
.jibe-color2-popover__cell {
  width: var(--jibe-color2-cell, 28px);
  height: var(--jibe-color2-cell, 28px);
  border: 1px solid rgba(255, 255, 255, 0.92);
  padding: 0;
  margin: 0;
  border-radius: 0;
  cursor: pointer;
  outline: none;
  background: var(--jibe-color2-bg, transparent) !important;
  background-color: var(--jibe-color2-bg, transparent) !important;
  /* subtle 3D / raised effect */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -1px 0 rgba(0, 0, 0, 0.22),
    0 1px 2px rgba(15, 23, 42, 0.18);
}
.jibe-color2-popover__cell:focus {
  outline: 2px solid rgba(29, 78, 216, 0.65);
  outline-offset: -2px;
}
.jibe-color2-popover__cell:active {
  box-shadow:
    inset 0 2px 3px rgba(0, 0, 0, 0.25),
    inset 0 -1px 0 rgba(255, 255, 255, 0.35);
}

.jibe-form__columns {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
}

.jibe-form__column {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.jibe-form__column--primary,
.jibe-form__column--secondary {
  width: 100%;
}

.jibe-form__section--two-col .jibe-form__columns {
  display: grid;
  gap: 0.6rem 0.75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.jibe-form__section--two-col .jibe-form__columns--single {
  grid-template-columns: minmax(0, 1fr);
}

.jibe-form__subsection {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 10px 0 0 0;
}

.jibe-form__subsection--width-100 {
  width: 100%;
}

.jibe-form__subsection-columns {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.jibe-form__subsection--two-col .jibe-form__subsection-columns {
  display: grid;
  gap: 0.6rem 0.75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.jibe-form__subsection--two-col .jibe-form__subsection-columns--single {
  grid-template-columns: minmax(0, 1fr);
}

.jibe-form__subsection-column {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.jibe-form__subsection .jibe-form__field {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0 0 0.75rem;
}

.jibe-form__subsection .jibe-form__field-label {
  font-size: 13px;
}

.jibe-form__subsection .jibe-form__field-input,
.jibe-form__subsection .jibe-form__field-value {
  padding-top: 0.35rem;
}

.jibe-form__subsection-header {
  margin-bottom: 0.5rem;
  display: none;
}

.jibe-form__subsection-title {
  color: #0f172a;
  font-size: 1rem;
  font-weight: 600;
}

.jibe-form__subsection-description {
  color: #475569;
  font-size: 0.9rem;
  margin-top: 0.2rem;
}

.jibe-form__subsection--has-header .jibe-form__subsection-header {
  display: block;
}

.jibe-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.4rem 0;
}

.jibe-form__field--width-100 {
  width: 100% !important;
  flex: 1 1 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.jibe-form__field--width-100 .jibe-form__field-input {
  width: 100%;
  max-width: 100%;
}

.jibe-form__field--width-100 .jibe-form__field-input {
  width: 100%;
  max-width: 100%;
}

.jibe-form__field--width-100 .jibe-form__field-input input,
.jibe-form__field--width-100 .jibe-form__field-input textarea,
.jibe-form__field--width-100 .jibe-form__field-input select,
.jibe-form__field--width-100 .jibe-form__field-input .foswikiInputField,
.jibe-form__field--width-100 .jibe-form__field-input .jqSelect2 {
  width: 100% !important;
  max-width: 100% !important;
  display: block;
  box-sizing: border-box;
}

/* Slider field type (Foswiki::Form::Slider) renders a .jqSliderContainer
   with an inline `width: ${size}em` that doesn't know about its parent
   column. In two-column form mode the inline em width often exceeds the
   ~½-form-width column and the slider track spills across both columns.
   Cap the container at the column's content width and shrink the value
   label so the track keeps a usable amount of room on narrow layouts. */
.jibe-form__field-input .jqSliderContainer {
  width: 100% !important;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}
.jibe-form__field-input .jqSliderContainer .jqSliderElem {
  flex: 1 1 auto;
  min-width: 0;
}
.jibe-form__field-input .jqSliderContainer .jqSliderLabel {
  min-width: 3em;
  flex-shrink: 0;
  text-align: right;
}

.jibe-form__field--has-rows {
  --jibe-field-rows: 1;
}

.jibe-form__field--has-rows .jibe-form__field-input textarea {
  min-height: calc(1.75rem * var(--jibe-field-rows));
  height: auto;
}

.jibe-form__field--spacer {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0.4rem 0;
  pointer-events: none;
  visibility: hidden;
  min-height: 3.5rem;
}

.jibe-currency {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.foswikiDecimalField,
.foswikiIntegerField {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.foswikiDecimalField::placeholder,
.foswikiIntegerField::placeholder {
  text-align: right;
}

.jibe-currency input.foswikiInputField {
  text-align: right;
}

.jibe-currency--suffix {
  flex-direction: row;
}

.jibe-currency__symbol {
  font-weight: 600;
  color: #0f172a;
}

.jibe-currency__display {
  white-space: nowrap;
}

.jibe-address {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.jibe-address__line {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.jibe-address__sub-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #0f172a;
}

.jibe-address__sub-input input,
.jibe-address__sub-input textarea,
.jibe-address__sub-input select {
  width: 100%;
  max-width: 100%;
}

.jibe-address__line--postal .jibe-address__sub-input {
  /* Prevent form-wide width-100 rules from forcing the postal input to stretch */
  display: inline-block !important;
  width: auto !important;
  max-width: 100% !important;
}

.jibe-address__line--postal .jibe-address__sub-input input,
.jibe-address__line--postal .jibe-address__sub-input input.foswikiInputField,
.jibe-address__line--postal .jibe-address__sub-input .foswikiInputField {
  display: inline-block !important;
  /* Match Select3 sizing used by "State or Province" (size=20 => data-width=20em) */
  width: 20em !important;
  min-width: 300px !important; /* mirrors .select3-container min-width */
  max-width: 100% !important;
}

.jibe-address__display {
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.jibe-address__display-title {
  font-weight: 600;
  color: #0f172a;
}

.jibe-address__display-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.jibe-address__row-label {
  font-size: 0.85rem;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.jibe-address__row-value {
  font-size: 13px;
  color: #0f172a;
}

.jibe-form__field-label {
  color: #0f172a;
  font-size: 13px;
  font-weight: 600;
}

.jibe-tooltip__container {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  position: relative;
}

.jibe-tooltip__trigger {
  appearance: none;
  background: transparent;
  border: none;
  border-radius: 999px;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0.15rem;
  transition: color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.jibe-tooltip__trigger:hover,
.jibe-tooltip__trigger:focus-visible {
  color: #1d4ed8;
  background-color: rgba(59, 130, 246, 0.12);
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.jibe-tooltip__icon {
  font-style: normal;
  font-size: 0.95rem;
  line-height: 1;
  pointer-events: none;
}

.jibe-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #0f172a;
  color: #f8fafc;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.35;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  min-width: 180px;
  max-width: 260px;
  z-index: 5;
}

.jibe-tooltip::after {
  content: "";
  position: absolute;
  top: -6px;
  left: 16px;
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent #0f172a transparent;
}

.jibe-tooltip.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

@media (max-width: 640px) {
  .jibe-tooltip {
    left: auto;
    right: 0;
    max-width: min(280px, 80vw);
  }

  .jibe-tooltip::after {
    left: auto;
    right: 16px;
  }
}

.jibe-form__field-input,
.jibe-form__field-value {
  font-size: 13px;
  line-height: 1.4;
}

/* ===== Uniform typography across every form control ===========================
   Several upstream stylesheets (jibe-shared.css, NatEditPlugin/styles.css,
   JQSelect2Contrib, jQueryUI) set conflicting font-family / font-size values
   on the underlying <input>, <textarea>, <select>, and Select2 chrome. Without
   an authoritative override the same row renders text inputs at one size,
   textareas in a monospace face, and Select2 chips at yet another size. We
   normalize here so every editable widget inherits its surrounding label
   typography (13px, sans-serif), giving the dialog a single visual rhythm and
   matching the related-list table cells (jibe-modern.css `.foswikiTable` 13px).
   `.foswikiInputField` is included explicitly because jibe-shared.css ties it
   to `var(--input-font-size)` and `.ui-natedit textarea` ties textareas to a
   monospace font with `var(--input-font-size, 12px)` -- both win over .jibe-form__field-input
   without an equally specific selector.
   ============================================================================ */
.jibe-form,
.jibe-form input,
.jibe-form textarea,
.jibe-form select,
.jibe-form .foswikiInputField,
.jibe-form .foswikiSelect,
.jibe-form .foswikiTextarea,
.jibe-form .ui-natedit textarea,
.jibe-form .select2-container,
.jibe-form .select2-container .select2-selection__rendered,
.jibe-form .select2-container .select2-selection__choice,
.jibe-form .select2-container .select2-search__field,
.jibe-form .select2-container .select2-results__option,
.jibe-form .select2-container--default .select2-selection--single .select2-selection__rendered,
.jibe-form .select2-container--default .select2-selection--multiple .select2-selection__rendered,
.jibe-form .select2-choice,
.jibe-form .select2-choices,
.jibe-form .select2-choices .select2-search-choice,
.jibe-form .select2-choices .select2-search-field input {
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
}

/* Select2 dropdown panes are portaled to <body>, outside .jibe-form, so the
   selectors above don't reach them. Match the Select2 widget itself in the
   form by tagging the dropdown when it's owned by a Jibe form via the global
   Select2 dropdown class. Same size keeps the open list consistent with the
   chip rendering above. */
body > .select2-container .select2-results__option,
body > .select2-container .select2-search__field {
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
}

.jibe-form__field-meta {
  color: #dc2626;
  font-size: 0.85rem;
  margin-left: 0.4rem;
}

.jibe-form__field--note {
  background: rgba(79, 70, 229, 0.08);
  border: 1px dashed rgba(79, 70, 229, 0.6);
  color: #312e81;
  font-weight: 600;
}

.jibe-form__legend {
  border-top: 1px solid rgba(15, 23, 42, 0.05);
  color: #475569;
  font-size: 0.85rem;
  padding: 1rem 1.75rem;
}

@media (max-width: 768px) {
  .jibe-form__section--two-col .jibe-form__columns {
    grid-template-columns: 1fr;
  }

  .jibe-form__subsection--two-col .jibe-form__subsection-columns {
    grid-template-columns: 1fr;
  }

  .jibe-form__sections {
    padding: 1.25rem;
  }
}

/* --- Recurrence composite field --- */
.jibe-recurrence {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.jibe-recurrence__line {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.jibe-recurrence__sub-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #0f172a;
}

.jibe-recurrence__sub-input input,
.jibe-recurrence__sub-input select {
  width: 100%;
  max-width: 100%;
}

.jibe-recurrence__line--enabled .jibe-recurrence__sub-input input[type="checkbox"] {
  width: auto;
  max-width: none;
}

.jibe-recurrence__line--interval .jibe-recurrence__sub-input,
.jibe-recurrence__line--dom .jibe-recurrence__sub-input,
.jibe-recurrence__line--maxocc .jibe-recurrence__sub-input {
  display: inline-block !important;
  width: auto !important;
  max-width: 100% !important;
}

.jibe-recurrence__line--interval .jibe-recurrence__sub-input input,
.jibe-recurrence__line--dom .jibe-recurrence__sub-input input,
.jibe-recurrence__line--maxocc .jibe-recurrence__sub-input input {
  display: inline-block !important;
  width: 6em !important;
  max-width: 100% !important;
}

.jibe-recurrence__line--enddate .jibe-recurrence__sub-input input {
  display: inline-block !important;
  width: 14em !important;
  max-width: 100% !important;
}

.jibe-recurrence__line--watermark {
  display: none !important;
}

.jibe-recurrence[data-enabled="No"] .jibe-recurrence__line:not(.jibe-recurrence__line--enabled) {
  display: none;
}

.jibe-recurrence:not([data-frequency="Weekly"]):not([data-frequency="Biweekly"]) .jibe-recurrence__line--dow {
  display: none;
}

.jibe-recurrence:not([data-frequency="Monthly"]):not([data-frequency="Quarterly"]):not([data-frequency="Yearly"]) .jibe-recurrence__line--dom {
  display: none;
}

/* ========================================================================
 * Phase 0 three-state lookup indicator
 *
 * Linked-record references render in one of three states based on the
 * referenced record's data_object.active value plus existence:
 *
 *   active   .jibe-lookup-link            normal link, no extra style
 *   inactive .jibe-lookup-link--inactive  gray + strikethrough, kept
 *                                          clickable so users can audit
 *                                          why a row was deactivated
 *   missing  .jibe-lookup-link--missing   non-clickable placeholder for
 *                                          deleted records or records
 *                                          the viewer lacks permission
 *                                          to see
 *
 * Emitted by:
 *   - Foswiki::Form::Lookup::getDisplayValue (single-record form view)
 *   - JibeDatabasePlugin::Util::_dbTableFormatLinkedName (dbTable / lists
 *     / RELATEDENTITY widgets)
 * ======================================================================== */

.jibe-lookup-link--inactive,
a.jibe-lookup-link--inactive,
a.jibe-lookup-link--inactive:visited {
  color: var(--text-muted, #94a3b8) !important;
  text-decoration: line-through !important;
  text-decoration-thickness: 1px !important;
  text-decoration-color: rgba(148, 163, 184, 0.7) !important;
  cursor: pointer;
}

a.jibe-lookup-link--inactive:hover {
  color: var(--text-secondary, #64748b) !important;
  text-decoration-color: rgba(100, 116, 139, 0.9) !important;
}

.jibe-lookup-link--missing {
  color: var(--text-muted, #94a3b8) !important;
  font-style: italic;
  cursor: help;
}
