.um-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.um-header h1 {
    font-size: 24px;
    font-weight: 800;
    color: #071b63;
    margin: 0;
}

.um-header p {
    margin: 4px 0 0;
    color: #5b6b8c;
    font-size: 14px;
}

.um-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    background: #eef2fb;
    color: #071b63;
}

.um-btn-primary {
    background: #2453ff;
    color: #fff;
}

.um-btn-secondary {
    background: #eef2fb;
    color: #071b63;
}

.um-btn-ghost {
    background: transparent;
    border-color: #dbe4f0;
    color: #45527a;
}

.um-btn:hover {
    filter: brightness(0.97);
}

.um-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 18px;
    font-size: 14px;
    font-weight: 600;
}

.um-alert-success {
    background: #ecfdf5;
    border: 1px solid #86efac;
    color: #166534;
}

.um-alert-danger {
    background: #fff1f2;
    border: 1px solid #fecdd3;
    color: #be123c;
}

.um-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}

.um-search {
    flex: 1 1 260px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #dbe4f0;
    border-radius: 10px;
    padding: 0 12px;
    height: 44px;
    background: #fff;
}

.um-search input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 14px;
}

.um-toolbar select {
    height: 44px;
    border: 1px solid #dbe4f0;
    border-radius: 10px;
    padding: 0 12px;
    font-size: 14px;
    background: #fff;
}

.um-table-wrap {
    overflow-x: auto;
    border: 1px solid #e7ecf4;
    border-radius: 14px;
}

.um-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

.um-table th,
.um-table td {
    text-align: left;
    padding: 14px 15px;
    font-size: 13px;
    border-bottom: 1px solid #eef2f7;
    vertical-align: middle;
}

.um-table th {
    background: #f7f9fd;
    color: #45527a;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.um-table tbody tr:last-child td {
    border-bottom: none;
}

.um-user-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    color: #071b63;
    white-space: nowrap;
}

.um-user-sub {
    color: #7a86a1;
    font-size: 12px;
}

.um-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.um-badge-active {
    background: #dcfce7;
    color: #166534;
}

.um-badge-inactive {
    background: #fee2e2;
    color: #991b1b;
}

.um-badge-admin {
    background: #e0e7ff;
    color: #3730a3;
}

.um-badge-user {
    background: #f1f5f9;
    color: #475569;
}

.um-badge-primary {
    background: #fef3c7;
    color: #92400e;
    margin-left: 6px;
}

.um-badge-pending {
    background: #fff7ed;
    color: #9a3412;
    margin-left: 6px;
}

.um-row-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.um-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid #dbe4f0;
    background: #fff;
    color: #45527a;
    cursor: pointer;
    text-decoration: none;
}

.um-icon-btn.danger {
    color: #be123c;
    border-color: #fecdd3;
}

.um-icon-btn.success {
    color: #166534;
    border-color: #86efac;
}

.um-icon-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.um-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.um-page-links {
    display: flex;
    gap: 6px;
}

.um-page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid #dbe4f0;
    color: #45527a;
    text-decoration: none;
    font-size: 14px;
}

.um-page-link.active {
    background: #2453ff;
    border-color: #2453ff;
    color: #fff;
}

.um-page-link.disabled {
    opacity: .45;
    pointer-events: none;
}

.um-form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.um-field {
    display: flex;
    flex-direction: column;
}

.um-field.full {
    grid-column: span 2;
}

.um-field label {
    font-size: 13px;
    font-weight: 700;
    color: #071b63;
    margin-bottom: 8px;
}

.um-field input,
.um-field select {
    height: 46px;
    border: 1px solid #dbe4f0;
    border-radius: 10px;
    padding: 0 14px;
    font-size: 14px;
}

.um-field input:focus,
.um-field select:focus {
    outline: none;
    border-color: #2453ff;
    box-shadow: 0 0 0 3px rgba(36,83,255,.08);
}

.um-check {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.um-check input {
    width: 18px;
    height: 18px;
    accent-color: #2453ff;
}

.um-form-actions {
    margin-top: 24px;
    display: flex;
    gap: 12px;
}

.um-readonly {
    background: #f7f9fd;
    color: #5b6b8c;
}

.um-empty {
    text-align: center;
    padding: 40px 20px;
    color: #7a86a1;
}

.text-danger {
    color: #dc2626;
    font-size: 12px;
    margin-top: 5px;
}

@media (max-width: 768px) {
    .um-form-grid {
        grid-template-columns: 1fr;
    }

    .um-field.full {
        grid-column: auto;
    }
}

/* ============================================================
   Sub-Organization (Building) management additions
   ============================================================ */
.um-section-title {
    margin: 24px 0 12px;
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 6px;
}

.um-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

    .um-toolbar input[type="text"] {
        flex: 1 1 260px;
        padding: 8px 12px;
        border: 1px solid #d1d5db;
        border-radius: 8px;
    }

.building-search-field {
    position: relative;
    flex: 0 1 280px;
    display: flex;
    align-items: center;
}

.building-search-field input[type="text"] {
    flex: 1 1 auto;
    width: 100%;
    padding: 8px 34px 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
}

.building-search-clear {
    position: absolute;
    top: 50%;
    right: 6px;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transform: translateY(-50%);
    transition: background .15s ease, color .15s ease;
}

.building-search-clear:hover {
    background: #f1f5f9;
    color: #475569;
}

.building-search-field:not(.has-value) .building-search-clear {
    display: none;
}

.um-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #374151;
    white-space: nowrap;
}

.um-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px 24px;
    margin: 0 0 8px;
}

    .um-detail-grid dt {
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: #6b7280;
        margin-bottom: 2px;
    }

    .um-detail-grid dd {
        margin: 0;
        font-size: 14px;
        color: #1f2937;
    }

/* ============================================================
   Add User modal (Buildings grid)
   ============================================================ */
.um-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.55);
    z-index: 1050;
    align-items: flex-start;
    justify-content: center;
    padding: 48px 16px;
    overflow-y: auto;
}

    .um-modal-overlay.open {
        display: flex;
    }

.um-modal {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 640px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    animation: umModalIn .15s ease-out;
}

@keyframes umModalIn {
    from { transform: translateY(-8px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.um-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid #e5e7eb;
}

    .um-modal-header h2 {
        margin: 0;
        font-size: 18px;
        font-weight: 600;
        color: #111827;
    }

.um-modal-sub {
    display: inline-block;
    margin-left: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
}

.um-modal-close {
    border: none;
    background: transparent;
    font-size: 26px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
}

    .um-modal-close:hover {
        color: #111827;
    }

.um-modal-body {
    padding: 20px 22px;
}

.um-modal-footer {
    display: flex;
    gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid #e5e7eb;
}

.um-hint { font-size: 13px; color: #6b7280; margin: 0 0 12px; }

/* ============================================================
   Compliance limits grid — status badges, small/coloured
   action buttons, sub-headers and info alert (State Defaults).
   ============================================================ */
.um-subheader { margin: 18px 0 8px; }
.um-subheader h2 { color: #0b1b4d; }

.um-badge-success { background: #dcfce7; color: #166534; }
.um-badge-info    { background: #dbeafe; color: #1e40af; }
.um-badge-muted   { background: #f1f5f9; color: #475569; }

.um-alert-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
}

.um-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.um-btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 8px;
    gap: 5px;
}

.um-btn-success { background: #16a34a; color: #fff; }
.um-btn-warning { background: #f59e0b; color: #3b2600; }
.um-btn-danger  { background: #dc2626; color: #fff; }

/* State-compliance grid: separate each state group with a heavier top border, and
   give the search box room. */
#stateGrid tbody tr.state-start td { border-top: 2px solid #cbd5e1; }
#stateGrid tbody tr.grid-row:first-child td { border-top: none; }
#gridSearch { width: 100%; }

/* ---------- State-compliance edit popup ---------- */
.wv-hidden-form { display: none; }
.wv-modal-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.5);
    display: none; align-items: flex-start; justify-content: center;
    z-index: 1000; padding: 40px 16px; overflow-y: auto;
}
.wv-modal-overlay.open { display: flex; }
.wv-modal {
    background: #fff; border-radius: 14px; width: 100%; max-width: 760px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.wv-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px; border-bottom: 1px solid #e5e9f2;
}
.wv-modal-head h2 { margin: 0; font-size: 1.15rem; color: #0b1b4d; }
.wv-modal-close { background: none; border: none; font-size: 1.7rem; line-height: 1; cursor: pointer; color: #64748b; }
.wv-modal-body { padding: 20px 22px; }
.wv-modal-records { margin-top: 14px; }
.wv-records { display: flex; flex-direction: column; gap: 6px; }
.wv-record {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 10px; background: #f8fafc; border-radius: 8px; font-size: 13px;
}
.wv-record-actions { display: flex; gap: 6px; }

/* Segmented account-type chips (compliance popups) */
.wv-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.wv-chip {
    border: 0.5px solid #cbd5e1; background: #fff; color: #45527a;
    border-radius: 20px; padding: 6px 14px; font-size: 13px; font-weight: 500; cursor: pointer;
}
.wv-chip.active { background: #2453ff; color: #fff; border-color: #2453ff; }
