/* Shared portal presentation contract 1. Adapted from the licensed Tailwind Plus Application UI
   form/input/combobox patterns, using the existing CIP brand and 14px typography.
   Public --portal-* tokens inherit from the host or a narrower presentation root.
   Resolve defaults privately here: never reset the host or unrelated module generations. */
.portal-theme[data-portal-theme-contract="1"],
[data-portal-theme-host-contract="1"] #components-reconnect-modal {
    --_portal-font: var(--portal-font-family, var(--nm-font-sans, "Segoe UI", sans-serif));
    --_portal-size: var(--portal-font-size, var(--cip-text-body, 14px));
    --_portal-help: var(--portal-help-font-size, var(--cip-text-help, 13px));
    --_portal-line: var(--portal-line-height, 1.5);
    --_portal-text: var(--portal-color-text, var(--nm-z900, #18181b));
    --_portal-muted: var(--portal-color-muted, var(--nm-z600, #52525b));
    --_portal-surface: var(--portal-color-surface, #fff);
    --_portal-subtle: var(--portal-color-surface-subtle, var(--nm-z50, #fafafa));
    --_portal-border: var(--portal-color-border, var(--nm-z300, #d4d4d8));
    --_portal-divider: var(--portal-color-divider, var(--nm-z200, #e4e4e7));
    --_portal-accent: var(--portal-color-accent, var(--nm-blue, #0d4f8a));
    --_portal-on-accent: var(--portal-color-on-accent, #fff);
    --_portal-focus: var(--portal-color-focus, var(--_portal-accent));
    --_portal-selection: var(--portal-color-selection, #eef5fc);
    --_portal-error: var(--portal-color-error, #b42318);
    --_portal-error-bg: var(--portal-color-error-surface, #fff5f5);
    --_portal-error-border: var(--portal-color-error-border, #f3c2c2);
    --_portal-radius: var(--portal-control-radius, 8px);
    --_portal-panel-radius: var(--portal-panel-radius, var(--nm-radius-lg, 12px));
    --_portal-height: var(--portal-control-height, 36px);
    --_portal-gap: var(--portal-field-gap, 6px);
    --_portal-padding: var(--portal-control-padding, 7px 10px);
    --_portal-shadow: var(--portal-control-shadow, 0 1px 2px rgba(0, 0, 0, .05));
    font-family: var(--_portal-font);
    font-size: var(--_portal-size);
    line-height: var(--_portal-line);
    color: var(--_portal-text);
    color-scheme: var(--portal-color-scheme, light);
}

.portal-theme[data-portal-theme-contract="1"] *,
.portal-theme[data-portal-theme-contract="1"] *::before,
.portal-theme[data-portal-theme-contract="1"] *::after { box-sizing: border-box; }

/* Native fields remain useful for free text and identifiers. Shared searchable controls
   use these same field rules rather than each module inventing its own visual kit. */
.portal-theme[data-portal-theme-contract="1"] :where(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="button"]):not([type="submit"]):not([type="range"]):not([type="color"]), select, textarea) {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: var(--_portal-height);
    padding: var(--_portal-padding);
    border: 1px solid var(--_portal-border);
    border-radius: var(--_portal-radius);
    background: var(--_portal-surface);
    color: var(--_portal-text);
    box-shadow: var(--_portal-shadow);
    font: inherit;
    line-height: var(--_portal-line);
}
.portal-theme[data-portal-theme-contract="1"] textarea { min-height: 96px; resize: vertical; }
.portal-theme[data-portal-theme-contract="1"] :where(input, textarea)::placeholder { color: var(--_portal-muted); opacity: 1; }
.portal-theme[data-portal-theme-contract="1"] :where(input, select, textarea, button, a, summary):focus-visible {
    outline: 2px solid var(--_portal-focus);
    outline-offset: 2px;
}
.portal-theme[data-portal-theme-contract="1"] :where(input, select, textarea):disabled {
    background: var(--_portal-subtle);
    color: var(--_portal-muted);
    cursor: not-allowed;
    opacity: 1;
}
.portal-theme[data-portal-theme-contract="1"] :where(input, textarea)[readonly] { background: var(--_portal-subtle); }
.portal-theme[data-portal-theme-contract="1"] :where(input, select, textarea)[aria-invalid="true"],
.portal-theme[data-portal-theme-contract="1"] :where(input, select, textarea).invalid { border-color: var(--_portal-error); }
.portal-theme[data-portal-theme-contract="1"] :where(input[type="checkbox"], input[type="radio"]) {
    width: 16px;
    height: 16px;
    margin: 0;
    flex: none;
    vertical-align: middle;
    accent-color: var(--_portal-accent);
}
.portal-theme[data-portal-theme-contract="1"] input[type="file"] { max-width: 100%; color: var(--_portal-text); font: inherit; }
.portal-theme[data-portal-theme-contract="1"] input[type="file"]::file-selector-button {
    min-height: var(--_portal-height);
    margin-right: 8px;
    padding: 7px 12px;
    border: 1px solid var(--_portal-border);
    border-radius: var(--_portal-radius);
    background: var(--_portal-surface);
    color: var(--_portal-text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.portal-theme[data-portal-theme-contract="1"] :where(label, .portal-field-label) { color: var(--_portal-text); font-weight: 500; }
.portal-theme[data-portal-theme-contract="1"] :where(small, .portal-field-help, .field-help) {
    color: var(--_portal-muted);
    font-size: var(--_portal-help);
}
.portal-theme[data-portal-theme-contract="1"] :where(.validation-message, .portal-field-error) {
    color: var(--_portal-error);
    font-size: var(--_portal-help);
}
.portal-theme[data-portal-theme-contract="1"] .portal-field { display: flex; flex-direction: column; gap: var(--_portal-gap); min-width: 0; }
.portal-theme[data-portal-theme-contract="1"] .portal-form { display: grid; gap: 8px; min-width: 0; text-align: left; }
.portal-theme[data-portal-theme-contract="1"] .portal-form > h1 { margin: 0 0 8px; font-size: 1.5rem; line-height: 1.25; }
.portal-theme[data-portal-theme-contract="1"] .portal-fields { margin: 16px 0; min-width: 0; }
.portal-theme[data-portal-theme-contract="1"] .portal-fields > label { display: block; margin: 8px 0 6px; }
.portal-theme[data-portal-theme-contract="1"] .portal-fields > :where(input, textarea, select, .nm-typeahead) { max-width: 32rem; margin-bottom: 8px; }
.portal-theme[data-portal-theme-contract="1"] .portal-fields > .field-help { margin: 0 0 12px; }
.portal-theme[data-portal-theme-contract="1"] fieldset { min-width: 0; }
.portal-theme[data-portal-theme-contract="1"] legend { font-weight: 600; }
.portal-theme[data-portal-theme-contract="1"] button,
.portal-theme[data-portal-theme-contract="1"] .button-link {
    min-height: var(--_portal-height);
    padding: 7px 12px;
    border: 1px solid var(--_portal-border);
    border-radius: var(--_portal-radius);
    background: var(--_portal-surface);
    color: var(--_portal-text);
    box-shadow: var(--_portal-shadow);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.portal-theme[data-portal-theme-contract="1"] .button-link { display: inline-flex; align-items: center; text-decoration: none; }
.portal-theme[data-portal-theme-contract="1"] button[type="submit"],
.portal-theme[data-portal-theme-contract="1"] button.primary,
.portal-theme[data-portal-theme-contract="1"] .button-link.primary {
    border-color: var(--_portal-accent);
    background: var(--_portal-accent);
    color: var(--_portal-on-accent);
}
.portal-theme[data-portal-theme-contract="1"] :where(button, .button-link):hover { box-shadow: 0 0 0 1px var(--_portal-border); }
.portal-theme[data-portal-theme-contract="1"] button:disabled { opacity: .55; cursor: not-allowed; }

/* PortalInitialView owns all initial states, including their presentation. */
.portal-theme[data-portal-theme-contract="1"] .state-panel {
    max-width: 720px;
    margin: 24px auto;
    padding: 24px;
    border: 1px solid var(--_portal-divider);
    border-radius: var(--_portal-panel-radius);
    background: var(--_portal-surface);
    color: var(--_portal-text);
}
.portal-theme[data-portal-theme-contract="1"] .state-panel h1 { margin: 6px 0 12px; font-size: 1.5rem; line-height: 1.25; }
.portal-theme[data-portal-theme-contract="1"] .state-panel p { margin: 0 0 16px; }
.portal-theme[data-portal-theme-contract="1"] .state-panel .eyebrow { color: var(--_portal-muted); font-size: var(--_portal-help); font-weight: 600; }
.portal-theme[data-portal-theme-contract="1"] .state-panel--refused { border-left: 4px solid var(--_portal-error); }
.portal-theme[data-portal-theme-contract="1"] .state-panel .button-link { margin-right: 8px; }

/* Preserve the existing typeahead controller, keyboard model and positioning. */
.portal-theme[data-portal-theme-contract="1"] .nm-typeahead-field { color: var(--_portal-text); }
.portal-theme[data-portal-theme-contract="1"] .nm-typeahead-field > input { padding-right: 32px; }
.portal-theme[data-portal-theme-contract="1"] .nm-typeahead-multiple {
    border-color: var(--_portal-border);
    border-radius: var(--_portal-radius);
    background: var(--_portal-surface);
}
.portal-theme[data-portal-theme-contract="1"] .nm-typeahead-multiple > input { border: 0; box-shadow: none; }
.portal-theme[data-portal-theme-contract="1"] .nm-typeahead-list {
    border-color: var(--_portal-border);
    border-radius: var(--_portal-radius);
    background: var(--_portal-surface);
    color: var(--_portal-text);
    box-shadow: 0 8px 20px rgba(0, 0, 0, .12);
}
.portal-theme[data-portal-theme-contract="1"] .nm-typeahead-option { color: var(--_portal-text); }
.portal-theme[data-portal-theme-contract="1"] .nm-typeahead-option.is-active,
.portal-theme[data-portal-theme-contract="1"] .nm-typeahead-option:hover { background: var(--_portal-selection); }
.portal-theme[data-portal-theme-contract="1"] .nm-typeahead-option.is-active,
.portal-theme[data-portal-theme-contract="1"] .nm-typeahead-multiple:focus-within { outline-color: var(--_portal-focus); }
.portal-theme[data-portal-theme-contract="1"] .nm-typeahead-option[aria-disabled="true"] { color: var(--_portal-muted); }
.portal-theme[data-portal-theme-contract="1"] .nm-typeahead-spin { border-color: var(--_portal-divider); border-top-color: var(--_portal-muted); }
.portal-theme[data-portal-theme-contract="1"] :where(.nm-typeahead-note, .nm-typeahead-feedback) { color: var(--_portal-muted); }
.portal-theme[data-portal-theme-contract="1"] .nm-typeahead-chip { background: var(--_portal-subtle); color: var(--_portal-text); border-color: var(--_portal-border); }
.portal-theme[data-portal-theme-contract="1"] .nm-typeahead-chip button { min-height: 24px; padding: 0 4px; border: 0; box-shadow: none; background: transparent; }

/* Shared page-piece tokens also work outside the opt-in root through legacy fallbacks. */
.portal-theme[data-portal-theme-contract="1"] {
    --_portal-success: var(--portal-color-success, #13612e);
    --_portal-success-bg: var(--portal-color-success-surface, #e7f6ec);
    --_portal-warning: var(--portal-color-warning, #7a4d00);
    --_portal-warning-bg: var(--portal-color-warning-surface, #fff4d6);
    --_portal-info: var(--portal-color-information, #1e40af);
    --_portal-info-bg: var(--portal-color-information-surface, #e8f0fe);
}

/* Existing shared pickers opt into semantic colors/type without the full form geometry.
   Dense NM/Partner grid controls retain their host-owned width, height and spacing. */
:where(.nm-typeahead[data-portal-control-theme-contract="1"], select[data-portal-control-theme-contract="1"]) {
    font-family: var(--portal-font-family, inherit);
    font-size: var(--portal-font-size, inherit);
    color: var(--portal-color-text, var(--_portal-text, inherit));
}
/* Defaults must yield to contract field states and explicit host control styling. */
:where(.nm-typeahead[data-portal-control-theme-contract="1"] .nm-typeahead-field > input,
select[data-portal-control-theme-contract="1"]) {
    font-family: var(--portal-font-family, inherit);
    color: var(--portal-color-text, var(--_portal-text, var(--nm-z900, #18181b)));
    background: var(--portal-color-surface, var(--_portal-surface, #fff));
    border-color: var(--portal-color-border, var(--_portal-border, var(--nm-z300, #d4d4d8)));
    border-radius: var(--portal-control-radius, var(--_portal-radius, var(--nm-radius-lg, 6px)));
}
.nm-typeahead[data-portal-control-theme-contract="1"] .nm-typeahead-list {
    color: var(--portal-color-text, var(--_portal-text, #18181b));
    background: var(--portal-color-surface, var(--_portal-surface, #fff));
    border-color: var(--portal-color-border, var(--_portal-border, #e4e4e7));
}
.nm-typeahead[data-portal-control-theme-contract="1"] .nm-typeahead-option { color: inherit; }
.nm-typeahead[data-portal-control-theme-contract="1"] .nm-typeahead-option.is-active {
    background: var(--portal-color-selection, var(--_portal-selection, #dbeafe));
    outline-color: var(--portal-color-focus, var(--_portal-focus, #2563eb));
}
.nm-typeahead[data-portal-control-theme-contract="1"] .nm-typeahead-option[aria-disabled="true"] { color: var(--portal-color-muted, var(--_portal-muted, #71717a)); }
.nm-typeahead[data-portal-control-theme-contract="1"] :where(.nm-typeahead-note, .nm-typeahead-feedback) { color: var(--portal-color-muted, var(--_portal-muted, #52525b)); }
.nm-typeahead[data-portal-control-theme-contract="1"] .nm-typeahead-field > input:focus-visible,
select[data-portal-control-theme-contract="1"]:focus-visible { outline-color: var(--portal-color-focus, var(--_portal-focus, #2563eb)); }
