/* Minimal stylesheet — matches the informal SE UI conventions. Shares little
   with se.Web because the Management portal is smaller and staff-only. Later
   work can extract common tokens into a shared file. */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1f2937;
    background: #f9fafb;
}

.splash {
    padding: 2rem;
    color: #6b7280;
}

.page {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, #111827 0%, #1f2937 100%);
    color: #e5e7eb;
    padding: 1rem 0;
}

.sidebar .nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar .nav-brand {
    padding: 0.5rem 1.25rem 1.5rem;
    font-weight: 700;
    font-size: 1.125rem;
}

.sidebar .nav-link {
    color: #d1d5db;
    padding: 0.5rem 1.25rem;
    text-decoration: none;
    display: block;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

main { padding: 0 2rem 2rem; }

.top-row {
    padding: 1rem 0;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 1.5rem;
}

.portal-label {
    font-size: 0.875rem;
    color: #6b7280;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.list-header h1 { margin: 0; }

.breadcrumb {
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.breadcrumb a {
    color: #2563eb;
    text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }

.status-disabled { background: #e5e7eb; color: #374151; }
.status-invited { background: #fef3c7; color: #92400e; }

/* M29b — billing status badges (see BillingStatus enum). Cancelled stays
   tied to the existing red treatment; pastdue / pendingpayment share the
   yellow "attention" tone. */
.status-pendingpayment { background: #fef3c7; color: #92400e; }
.status-pastdue { background: #fef3c7; color: #92400e; }

.billing-summary {
    display: grid;
    grid-template-columns: 180px 1fr;
    row-gap: 0.5rem;
    column-gap: 1rem;
    margin-top: 1rem;
}

.billing-summary dt {
    font-weight: 600;
    color: #6b7280;
    font-size: 0.875rem;
}

.billing-summary dd { margin: 0; }

.billing-summary code {
    background: #f3f4f6;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.875rem;
}

.billing-ids code { margin-right: 0.5rem; }

.billing-empty {
    background: #f9fafb;
    border: 1px dashed #d1d5db;
    border-radius: 6px;
    padding: 1.5rem;
}

.billing-actions {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.btn-primary, .btn-secondary, .btn-link {
    font-size: 0.875rem;
    padding: 0.5rem 0.875rem;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn-primary {
    background: #2563eb;
    color: white;
}

.btn-primary:hover:not(:disabled) { background: #1d4ed8; }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.btn-secondary {
    background: #f3f4f6;
    color: #1f2937;
    border-color: #d1d5db;
}

.btn-link {
    background: transparent;
    color: #2563eb;
    border: none;
    padding: 0.25rem 0.5rem;
}

.btn-link:hover { text-decoration: underline; }

.btn-danger-link { color: #b91c1c; }

/* 2026-06-11 — header identity popover (mirrors se.Web). The signed-in
   name toggles a small right-aligned card with name + email; role chips
   render when the directory resolves the caller. */
.login-identity {
    position: relative;
    display: inline-block;
}
.identity-popover {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    z-index: 60;
    min-width: 14rem;
    max-width: 20rem;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
    padding: 0.75rem 0.9rem;
    text-align: left;
}
.identity-popover p { margin: 0; }
.identity-popover-name {
    font-weight: 600;
    color: #1f2937;
}
.identity-popover-email {
    color: #6b7280;
    font-size: 0.85rem;
    margin-top: 0.15rem;
    overflow-wrap: anywhere;
}
.identity-popover-roles-label {
    margin-top: 0.6rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9ca3af;
}
.identity-popover-roles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.3rem;
}
.identity-popover-roles .chip {
    background: #eef2ff;
    color: #3730a3;
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
    font-size: 0.78rem;
    white-space: nowrap;
}

.data-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-grid th,
.data-grid td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.data-grid th {
    background: #f3f4f6;
    font-weight: 600;
}

.col-actions { text-align: right; white-space: nowrap; }

.status {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.status-active { background: #d1fae5; color: #065f46; }
.status-trialing { background: #dbeafe; color: #1e40af; }
.status-suspended { background: #fef3c7; color: #92400e; }
.status-cancelled { background: #fee2e2; color: #991b1b; }

.dialog-scrim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.dialog-card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    width: min(480px, 90vw);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    /* A tall form (e.g. the invite dialog's role/department/job-title pickers)
       must never grow past the viewport with no way to reach the actions —
       cap the card and let it scroll internally. */
    max-height: 90vh;
    overflow-y: auto;
}

.dialog-card h2 { margin: 0 0 1rem; }

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.form-field label {
    font-weight: 600;
    font-size: 0.875rem;
}

.form-field input,
.form-field select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 1rem;
}

.form-help {
    font-size: 0.75rem;
    color: #6b7280;
}

.form-error {
    color: #b91c1c;
    font-size: 0.875rem;
    padding: 0.5rem;
    background: #fef2f2;
    border-radius: 4px;
    margin: 0.75rem 0;
}

/* M351 — amber caution notice (e.g. invite email Skipped/not-configured),
   mirroring se.Web's .form-hint-attention. */
.form-hint-attention {
    color: #92400e;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    background: #fef3c7;
    border-left: 3px solid #d97706;
    border-radius: 3px;
    margin: 0.75rem 0;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Multi-select checkbox list (RolePicker / DepartmentMultiPicker /
   JobTitlePicker / UserTypeMultiPicker via MultiSelectPicker). se.Management
   previously left these unstyled, so each option's name and its (often long)
   description ran together inline and the list had no height cap — the invite
   dialog overflowed the viewport. Ported from se.Web with the Management
   palette. */
.multi-select-picker {
    margin-bottom: 1rem;
}
.multi-select-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.45rem;
}
.multi-select-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: white;
    max-height: 16rem;
    overflow-y: auto;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.multi-select-item {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
}
.multi-select-item:last-child {
    border-bottom: none;
}
.multi-select-item:hover {
    background: #f9fafb;
}
.multi-select-item input[type="checkbox"] {
    margin: 0.22rem 0 0 0;
    cursor: pointer;
    flex-shrink: 0;
}
.multi-select-item label {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    cursor: pointer;
    flex: 1;
    font-weight: 400;
}
.multi-select-item-label {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.92rem;
}
.multi-select-item-description {
    font-size: 0.8rem;
    color: #6b7280;
    line-height: 1.4;
}
.multi-select-empty {
    color: #6b7280;
    font-style: italic;
    padding: 0.75rem;
}
.multi-select-loading {
    color: #6b7280;
    padding: 0.5rem 0;
}

.error {
    padding: 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 4px;
    color: #991b1b;
}

.validation-message {
    color: #b91c1c;
    font-size: 0.75rem;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fee2e2;
    padding: 0.75rem;
    text-align: center;
}

/* ADR-53 (W1.g) — Marketing-leads admin viewer.
   Filter strip + detail-panel layout. Status colour classes for the four
   LeadStatus values pick from the existing status palette plus a couple
   of additions; same naming convention as .status-active / .status-suspended
   used by the Tenants page. */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    align-items: flex-end;
    margin: 1rem 0 1.5rem;
}

.filter-bar label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: #475569;
}

.filter-bar select,
.filter-bar input[type="search"],
.filter-bar input[type="text"] {
    padding: 0.4rem 0.6rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.25rem;
    background: #fff;
    font-size: 0.95rem;
    min-width: 12rem;
}

.filter-bar .search-label input { min-width: 18rem; }

.data-grid tr.selected {
    background: #fff7ed;
}

.muted { color: #64748b; font-size: 0.875rem; }

.detail-panel {
    margin-top: 1.5rem;
    padding: 1.25rem 1.5rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
}

.detail-panel header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1rem;
}

.detail-panel h2 { margin: 0; font-size: 1.25rem; }

.detail-panel dl {
    display: grid;
    grid-template-columns: 12rem 1fr;
    gap: 0.5rem 1rem;
    margin: 0;
}

.detail-panel dt {
    font-weight: 600;
    color: #475569;
    font-size: 0.875rem;
}

.detail-panel dd { margin: 0; }

.lead-message {
    margin: 0;
    white-space: pre-wrap;
    font-family: inherit;
    background: #fff;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.25rem;
}

.detail-actions {
    margin-top: 1.25rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.status-new          { background: #e0f2fe; color: #075985; }
.status-contacted    { background: #fef3c7; color: #92400e; }
.status-qualified    { background: #dcfce7; color: #166534; }
.status-disqualified { background: #f1f5f9; color: #475569; }

/* M239 / ADR-92 — Stacked-row entity list shape (mirror of se.Web's
   block; the staff portal carries its own copy of the global stylesheet
   per the ADR-50 staff-portal-separation posture). See the commentary
   in se.Web/wwwroot/css/app.css for the full rationale; this block adds
   only the row chrome and reuses the .status badges defined above. */
.entity-row-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}
.entity-row {
    position: relative;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.entity-row:hover {
    border-color: #c7d2fe;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.entity-row:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}
.entity-row-clickable {
    display: block;
    padding: 0.85rem 3rem 0.85rem 1rem;
    cursor: pointer;
    outline: none;
}
.entity-row-static {
    display: block;
    padding: 0.85rem 3rem 0.85rem 1rem;
}
.entity-row-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    font-size: 0.78rem;
    color: #6b7280;
}
.entity-row-severity {
    display: inline-flex;
    align-items: center;
}
.entity-row-meta {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
    color: #6b7280;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.72rem;
}
.entity-row-id { letter-spacing: 0.02em; }
.entity-row-title {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.35;
}
.entity-row-narrative {
    margin: 0 0 0.4rem 0;
    color: #4b5563;
    font-size: 0.88rem;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.entity-row-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.6rem;
    font-size: 0.78rem;
    color: #6b7280;
}
.chip {
    display: inline-block;
    background: #f3f4f6;
    color: #374151;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
}
/* M338 — provisioning-health chip: amber-tinted to read as "needs attention"
   without the alarm of a hard error. */
.chip-attention {
    background: #fef3c7;
    color: #92400e;
    font-weight: 600;
}
.entity-row-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}
.entity-row-actions > summary {
    list-style: none;
    cursor: pointer;
    width: 1.8rem;
    height: 1.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: #6b7280;
    font-size: 1.1rem;
    user-select: none;
}
.entity-row-actions > summary::-webkit-details-marker {
    display: none;
}
.entity-row-actions > summary:hover {
    background: #f3f4f6;
    color: #1f2937;
}
.entity-row-actions[open] > summary {
    background: #e5e7eb;
    color: #1f2937;
}
.entity-row-actions-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin: 0.25rem 0 0 0;
    padding: 0.3rem 0;
    list-style: none;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    min-width: 8rem;
    z-index: 10;
}
.entity-row-actions-menu li { display: block; }
.entity-row-actions-menu button {
    width: 100%;
    text-align: left;
    padding: 0.4rem 0.85rem;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    color: #1f2937;
}
.entity-row-actions-menu button:hover { background: #f3f4f6; }
.entity-row-actions-menu .btn-danger-link { color: #991b1b; }
.entity-row-actions-menu .btn-danger-link:hover { background: #fee2e2; }

@media (max-width: 640px) {
    .entity-row-clickable,
    .entity-row-static {
        padding: 0.7rem 2.6rem 0.7rem 0.8rem;
    }
    .entity-row-title { font-size: 0.95rem; }
    .entity-row-narrative { font-size: 0.85rem; }
}

/* ADR-147 (M481) — StaffAccessGate boot-guard screens (checking / denied /
   retry). Centered, full-viewport so a non-staff sign-in sees only this. */
.staff-gate {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    min-height: 100vh;
    padding: 2rem;
    text-align: center;
}
.staff-gate h1 { margin: 0; font-size: 1.5rem; color: #1f2937; }
.staff-gate p { margin: 0; max-width: 32rem; color: #334155; }
.staff-gate .staff-gate-hint { color: #64748b; font-size: 0.9rem; }

/* ADR-145 D5 (M484) — staff payment-history list on the tenant billing page. */
.billing-history { margin-top: 1.5rem; }
.billing-history-list { list-style: none; margin: 0; padding: 0; }
.billing-history-item {
    display: flex;
    gap: 1rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f1f5f9;
}
.billing-history-date { color: #64748b; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.8rem; white-space: nowrap; }
.billing-history-desc { color: #1f2937; }

/* M487 — checkout dialog busy state (spinner + "redirecting" line). */
.form-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.form-fieldset:disabled { opacity: 0.6; }
.checkout-redirecting {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.75rem 0 0;
    color: #475569;
    font-size: 0.9rem;
}
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #cbd5e1;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* "Learn more →" deep-link from [HelpGuide("...")] on a domain property.
   Sits next to the [Help] `?` chip on a generated form field and links to
   the User Guide library at /help/{Identifier}. Small + inline so it rides
   alongside the field label; matches the staff portal's blue link colour +
   underline-on-hover convention (.btn-link / .breadcrumb a). */
.help-guide-link {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 0.78rem;
    font-weight: 500;
    vertical-align: middle;
    white-space: nowrap;
    color: #2563eb;
    text-decoration: none;
}
.help-guide-link:hover { text-decoration: underline; }
