:root,
html[data-resolved-theme="light"] {
    --ui-bg: #f5f5f7;
    --ui-surface: #ffffff;
    --ui-surface-soft: #fafafa;
    --ui-surface-elevated: rgba(255,255,255,.94);
    --ui-text: #1d1d1f;
    --ui-muted: #6e6e73;
    --ui-line: rgba(0,0,0,.085);
    --ui-input: #ffffff;
    --ui-hover: #f2f2f4;
    --ui-shadow: rgba(0,0,0,.08);
    --ui-accent: #111111;
    --ui-accent-text: #ffffff;
}

html[data-resolved-theme="dark"] {
    color-scheme: dark;
    --ui-bg: #0d0d0f;
    --ui-surface: #1c1c1e;
    --ui-surface-soft: #242426;
    --ui-surface-elevated: rgba(28,28,30,.96);
    --ui-text: #f5f5f7;
    --ui-muted: #a1a1a6;
    --ui-line: rgba(255,255,255,.10);
    --ui-input: #242426;
    --ui-hover: #2c2c2e;
    --ui-shadow: rgba(0,0,0,.36);
    --ui-accent: #f5f5f7;
    --ui-accent-text: #111111;

    /* Override the variable names already used by the historical UI. */
    --bg: var(--ui-bg);
    --card: var(--ui-surface);
    --text: var(--ui-text);
    --muted: var(--ui-muted);
    --line: var(--ui-line);
    --line-strong: rgba(255,255,255,.16);
    --shadow: 0 16px 46px var(--ui-shadow);
    --accent: var(--ui-accent);
    --bs-body-bg: var(--ui-bg);
    --bs-body-color: var(--ui-text);
    --bs-border-color: var(--ui-line);
}

html[data-resolved-theme="dark"] body {
    background: var(--ui-bg) !important;
    color: var(--ui-text) !important;
}

html[data-resolved-theme="dark"] .admin-layout,
html[data-resolved-theme="dark"] .admin-content,
html[data-resolved-theme="dark"] .shell {
    background-color: var(--ui-bg) !important;
    color: var(--ui-text) !important;
}

html[data-resolved-theme="dark"] .admin-sidebar,
html[data-resolved-theme="dark"] .admin-card,
html[data-resolved-theme="dark"] .stat-card,
html[data-resolved-theme="dark"] .dashboard-card,
html[data-resolved-theme="dark"] .card,
html[data-resolved-theme="dark"] .topbar,
html[data-resolved-theme="dark"] .modal-content,
html[data-resolved-theme="dark"] .dropdown-menu,
html[data-resolved-theme="dark"] .table-wrap,
html[data-resolved-theme="dark"] .stat,
html[data-resolved-theme="dark"] .phase-card,
html[data-resolved-theme="dark"] .activity-card,
html[data-resolved-theme="dark"] .detail,
html[data-resolved-theme="dark"] .item {
    background: var(--ui-surface-elevated) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
    box-shadow: 0 18px 54px var(--ui-shadow) !important;
}

html[data-resolved-theme="dark"] .sidebar-link,
html[data-resolved-theme="dark"] .logout-button,
html[data-resolved-theme="dark"] .small-action-button,
html[data-resolved-theme="dark"] .row-action,
html[data-resolved-theme="dark"] .action,
html[data-resolved-theme="dark"] .back {
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
}

html[data-resolved-theme="dark"] .sidebar-link:hover,
html[data-resolved-theme="dark"] .sidebar-link.active,
html[data-resolved-theme="dark"] .small-action-button:hover,
html[data-resolved-theme="dark"] .row-action:hover,
html[data-resolved-theme="dark"] .action:hover {
    background: var(--ui-hover) !important;
}

html[data-resolved-theme="dark"] input,
html[data-resolved-theme="dark"] select,
html[data-resolved-theme="dark"] textarea,
html[data-resolved-theme="dark"] .admin-input,
html[data-resolved-theme="dark"] .input {
    background: var(--ui-input) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
}

html[data-resolved-theme="dark"] table,
html[data-resolved-theme="dark"] th,
html[data-resolved-theme="dark"] td {
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
}

html[data-resolved-theme="dark"] tbody tr:hover {
    background: var(--ui-hover) !important;
}

html[data-resolved-theme="dark"] .text-muted,
html[data-resolved-theme="dark"] .muted,
html[data-resolved-theme="dark"] .sub,
html[data-resolved-theme="dark"] .mono-sub,
html[data-resolved-theme="dark"] .field-help,
html[data-resolved-theme="dark"] .brand-subtitle,
html[data-resolved-theme="dark"] .sidebar-current-user span,
html[data-resolved-theme="dark"] .card-head p,
html[data-resolved-theme="dark"] .hero p {
    color: var(--ui-muted) !important;
}

.ui-preferences {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
}

.ui-preferences label {
    display: grid;
    gap: 5px;
    min-width: 128px;
    margin: 0;
}

.ui-preferences label > span {
    color: var(--ui-muted, #6e6e73);
    font-size: 11px;
    font-weight: 700;
}

.ui-preferences select,
.ui-preferences button {
    min-height: 36px;
    padding: 0 10px;
    border: 1px solid var(--ui-line, rgba(0,0,0,.1));
    border-radius: 10px;
    background: var(--ui-input, #fff);
    color: var(--ui-text, #1d1d1f);
    font: inherit;
    font-size: 12px;
}

.ui-preferences button {
    background: var(--ui-accent, #111);
    color: var(--ui-accent-text, #fff);
    cursor: pointer;
    font-weight: 700;
}

.ui-preferences-compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.ui-preferences-compact label {
    min-width: 0;
}

.ui-preferences-compact button {
    grid-column: 1 / -1;
    width: 100%;
}

.ui-preference-card {
    margin-top: 18px;
    padding: 16px;
    border: 1px solid var(--ui-line, rgba(0,0,0,.08));
    border-radius: 16px;
    background: var(--ui-surface-soft, #fafafa);
}

.ui-preference-card h3 {
    margin: 0 0 6px;
    font-size: 15px;
}

.ui-preference-card p {
    margin: 0 0 12px;
    color: var(--ui-muted, #6e6e73);
    font-size: 12px;
}

/* =========================================================
   V9.1 — icon-based language / appearance controls
   ========================================================= */

.ui-preferences-icons {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.ui-preferences-icons .ui-pref-group {
    display: grid;
    gap: 6px;
}

.ui-preferences-icons .ui-pref-label {
    color: var(--ui-muted, #6e6e73);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .01em;
}

.ui-preferences-icons .ui-pref-form {
    margin: 0;
}

.ui-preferences-icons .ui-pref-segment {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--ui-line, rgba(0,0,0,.085));
    border-radius: 14px;
    background: color-mix(in srgb, var(--ui-surface, #fff) 88%, transparent);
    box-shadow: 0 5px 18px rgba(0,0,0,.045);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.ui-preferences-icons .ui-pref-icon {
    position: relative;
    width: 40px;
    height: 34px;
    min-width: 40px;
    min-height: 34px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ui-muted, #6e6e73);
    cursor: pointer;
    transition:
        background-color .16s ease,
        color .16s ease,
        box-shadow .16s ease,
        transform .16s ease;
}

.ui-preferences-icons .ui-pref-icon:hover:not(:disabled) {
    background: var(--ui-hover, #f2f2f4);
    color: var(--ui-text, #1d1d1f);
    transform: translateY(-1px);
}

.ui-preferences-icons .ui-pref-icon:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.ui-preferences-icons .ui-pref-icon.is-active,
.ui-preferences-icons .ui-pref-icon:disabled {
    background: var(--ui-accent, #111);
    color: var(--ui-accent-text, #fff);
    box-shadow: 0 5px 13px rgba(0,0,0,.14);
    cursor: default;
    opacity: 1;
}

.ui-preferences-icons .ui-pref-language .ui-pref-icon {
    font-size: 20px;
    line-height: 1;
}

.ui-preferences-icons .ui-pref-icon-glyph {
    display: grid;
    place-items: center;
    line-height: 1;
}

.ui-preferences-icons .ui-pref-icon-glyph svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ui-preferences-icons .ui-pref-icon-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.ui-preferences-icons.ui-preferences-compact {
    display: flex;
    grid-template-columns: none;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
}

.ui-preferences-icons.ui-preferences-compact .ui-pref-group,
.ui-preferences-icons.ui-preferences-compact .ui-pref-form {
    display: flex;
}

.ui-preferences-icons.ui-preferences-compact .ui-pref-icon {
    width: 36px;
    min-width: 36px;
    height: 30px;
    min-height: 30px;
}

.ui-preferences-icons.ui-preferences-compact .ui-pref-language .ui-pref-icon {
    font-size: 18px;
}

.ui-preferences-icons.ui-preferences-compact .ui-pref-icon-glyph svg {
    width: 16px;
    height: 16px;
}

html[data-resolved-theme="dark"] .ui-preferences-icons .ui-pref-segment {
    background: rgba(28,28,30,.82);
    border-color: var(--ui-line);
    box-shadow: 0 7px 24px rgba(0,0,0,.24);
}

html[data-resolved-theme="dark"] .ui-preferences-icons .ui-pref-icon.is-active,
html[data-resolved-theme="dark"] .ui-preferences-icons .ui-pref-icon:disabled {
    background: #f5f5f7;
    color: #111;
}

/* Login page dark-mode contrast fixes. */
html[data-resolved-theme="dark"] .auth-content {
    background: var(--ui-bg) !important;
}

html[data-resolved-theme="dark"] .auth-card {
    background: var(--ui-surface-elevated) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
    box-shadow: 0 22px 70px var(--ui-shadow) !important;
}

html[data-resolved-theme="dark"] .auth-card h1,
html[data-resolved-theme="dark"] .auth-card h2,
html[data-resolved-theme="dark"] .auth-card h3,
html[data-resolved-theme="dark"] .auth-card label,
html[data-resolved-theme="dark"] .auth-card .form-label {
    color: var(--ui-text) !important;
}

html[data-resolved-theme="dark"] .auth-card .form-control {
    background: var(--ui-input) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
}

html[data-resolved-theme="dark"] .auth-card .btn-dark {
    background: #f5f5f7 !important;
    color: #111 !important;
    border-color: #f5f5f7 !important;
}

@media (max-width: 700px) {
    .ui-preferences-icons.ui-preferences-compact {
        gap: 5px;
    }

    .ui-preferences-icons.ui-preferences-compact .ui-pref-icon {
        width: 32px;
        min-width: 32px;
    }
}

/* =========================================================
   V9.2.1 — Dark mode white-control contrast fix
   ========================================================= */

/* Dashboard / top navigation */
html[data-resolved-theme="dark"] .top-nav a,
html[data-resolved-theme="dark"] .top-nav a:visited,
html[data-resolved-theme="dark"] .logout button {
    background: #f5f5f7 !important;
    color: #111111 !important;
    -webkit-text-fill-color: #111111 !important;
    border-color: rgba(255,255,255,.16) !important;
}

html[data-resolved-theme="dark"] .top-nav a:hover,
html[data-resolved-theme="dark"] .logout button:hover {
    background: #e7e7ea !important;
    color: #111111 !important;
    -webkit-text-fill-color: #111111 !important;
}

/* Dashboard row actions */
html[data-resolved-theme="dark"] .row-action,
html[data-resolved-theme="dark"] a.row-action,
html[data-resolved-theme="dark"] .row-action:visited {
    background: #f5f5f7 !important;
    color: #111111 !important;
    -webkit-text-fill-color: #111111 !important;
    border-color: rgba(255,255,255,.16) !important;
}

html[data-resolved-theme="dark"] .row-action:hover,
html[data-resolved-theme="dark"] a.row-action:hover {
    background: #e7e7ea !important;
    color: #111111 !important;
    -webkit-text-fill-color: #111111 !important;
}

html[data-resolved-theme="dark"] .row-action.danger,
html[data-resolved-theme="dark"] a.row-action.danger {
    background: #fff1f0 !important;
    color: #b42318 !important;
    -webkit-text-fill-color: #b42318 !important;
    border-color: rgba(177,35,24,.28) !important;
}

html[data-resolved-theme="dark"] .row-action.danger:hover,
html[data-resolved-theme="dark"] a.row-action.danger:hover {
    background: #ffe4e1 !important;
    color: #8f1d14 !important;
    -webkit-text-fill-color: #8f1d14 !important;
}

/* Other Super Admin pages that use white secondary controls */
html[data-resolved-theme="dark"] .nav a,
html[data-resolved-theme="dark"] .nav a:visited,
html[data-resolved-theme="dark"] .filters a:not(.active),
html[data-resolved-theme="dark"] .filters a:not(.active):visited,
html[data-resolved-theme="dark"] .back,
html[data-resolved-theme="dark"] .back:visited,
html[data-resolved-theme="dark"] .button.secondary,
html[data-resolved-theme="dark"] .secondary {
    background: #f5f5f7 !important;
    color: #111111 !important;
    -webkit-text-fill-color: #111111 !important;
}

html[data-resolved-theme="dark"] .button.danger,
html[data-resolved-theme="dark"] .retry,
html[data-resolved-theme="dark"] .retry:visited {
    background: #fff1f0 !important;
    color: #b42318 !important;
    -webkit-text-fill-color: #b42318 !important;
}

/* =========================================================
   V9.3 — remaining Super Admin pages
   ========================================================= */
.ui-pref-top {
    margin-left: auto;
}

html[data-resolved-theme="dark"] .form-card,
html[data-resolved-theme="dark"] .alert.info {
    background: var(--ui-surface-elevated) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
    box-shadow: 0 18px 54px var(--ui-shadow) !important;
}

html[data-resolved-theme="dark"] .btn-secondary,
html[data-resolved-theme="dark"] a.btn-secondary,
html[data-resolved-theme="dark"] .btn.secondary,
html[data-resolved-theme="dark"] a.btn.secondary {
    background: #f5f5f7 !important;
    color: #111111 !important;
    -webkit-text-fill-color: #111111 !important;
    border-color: rgba(255,255,255,.16) !important;
}

html[data-resolved-theme="dark"] .btn-primary,
html[data-resolved-theme="dark"] .btn.primary,
html[data-resolved-theme="dark"] .button:not(.secondary):not(.danger),
html[data-resolved-theme="dark"] .action {
    background: #f5f5f7 !important;
    color: #111111 !important;
    -webkit-text-fill-color: #111111 !important;
}

html[data-resolved-theme="dark"] .warning {
    background: #2b2518 !important;
    color: #f0cf78 !important;
    border-color: rgba(240,207,120,.18) !important;
}

html[data-resolved-theme="dark"] .error,
html[data-resolved-theme="dark"] .alert.error {
    background: #351c1c !important;
    color: #ffb4ae !important;
    border-color: rgba(255,180,174,.16) !important;
}

html[data-resolved-theme="dark"] .badge,
html[data-resolved-theme="dark"] .status:not(.active):not(.suspended):not(.disabled) {
    background: var(--ui-surface-soft) !important;
    color: var(--ui-text) !important;
}

html[data-resolved-theme="dark"] .security-note,
html[data-resolved-theme="dark"] .danger-list,
html[data-resolved-theme="dark"] .restore-list {
    background: #09090b !important;
    color: #f5f5f7 !important;
    border: 1px solid var(--ui-line) !important;
}

@media (max-width: 760px) {
    .ui-pref-top { margin-left: 0; }
}

/* =========================================================
   V9.5.1 — Tenant dashboard/account dark-mode surfaces
   ========================================================= */
html[data-resolved-theme="dark"] .account-information > div {
    background: var(--ui-surface-soft) !important;
    color: var(--ui-text) !important;
    border: 1px solid var(--ui-line) !important;
    box-shadow: none !important;
}

html[data-resolved-theme="dark"] .account-information > div span {
    color: var(--ui-muted) !important;
    -webkit-text-fill-color: var(--ui-muted) !important;
}

html[data-resolved-theme="dark"] .account-information > div strong {
    color: var(--ui-text) !important;
    -webkit-text-fill-color: var(--ui-text) !important;
}

/* Other historical tenant soft panels that still use fixed light backgrounds. */
html[data-resolved-theme="dark"] .permission-grid label,
html[data-resolved-theme="dark"] .employee-picker-no-photo,
html[data-resolved-theme="dark"] .room-empty-message {
    background: var(--ui-surface-soft) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
}

/* =========================================================
   V9.5.2 — Tenant full dark-mode surface normalization
   ========================================================= */

/* Secondary actions / historical light buttons */
html[data-resolved-theme="dark"] body .small-action-button,
html[data-resolved-theme="dark"] body a.small-action-button,
html[data-resolved-theme="dark"] body button.small-action-button,
html[data-resolved-theme="dark"] body .room-buttons a,
html[data-resolved-theme="dark"] body .room-buttons button:not(.room-delete-button),
html[data-resolved-theme="dark"] body .room-add-employee-button,
html[data-resolved-theme="dark"] body .category-button {
    background: var(--ui-surface-soft) !important;
    color: var(--ui-text) !important;
    -webkit-text-fill-color: var(--ui-text) !important;
    border: 1px solid var(--ui-line) !important;
    box-shadow: none !important;
}

html[data-resolved-theme="dark"] body .small-action-button:hover,
html[data-resolved-theme="dark"] body a.small-action-button:hover,
html[data-resolved-theme="dark"] body button.small-action-button:hover,
html[data-resolved-theme="dark"] body .room-buttons a:hover,
html[data-resolved-theme="dark"] body .room-buttons button:not(.room-delete-button):hover,
html[data-resolved-theme="dark"] body .room-add-employee-button:hover,
html[data-resolved-theme="dark"] body .category-button:hover {
    background: var(--ui-hover) !important;
    color: var(--ui-text) !important;
    -webkit-text-fill-color: var(--ui-text) !important;
}

/* Destructive actions keep a red semantic treatment without white cards. */
html[data-resolved-theme="dark"] body .delete-action-button,
html[data-resolved-theme="dark"] body .room-delete-button {
    background: #351c1c !important;
    color: #ffb4ae !important;
    -webkit-text-fill-color: #ffb4ae !important;
    border: 1px solid rgba(255,180,174,.16) !important;
}

html[data-resolved-theme="dark"] body .delete-action-button:hover,
html[data-resolved-theme="dark"] body .room-delete-button:hover {
    background: #452323 !important;
    color: #ffc7c2 !important;
    -webkit-text-fill-color: #ffc7c2 !important;
}

/* Historical tenant cards that were hard-coded white. */
html[data-resolved-theme="dark"] body .room-management-card,
html[data-resolved-theme="dark"] body .inventory-admin-card,
html[data-resolved-theme="dark"] body .room-management-item,
html[data-resolved-theme="dark"] body .employee-picker-box,
html[data-resolved-theme="dark"] body .employee-picker-row,
html[data-resolved-theme="dark"] body .employee-inventory-picker-row,
html[data-resolved-theme="dark"] body .room-summary-box {
    background: var(--ui-surface-elevated) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
    box-shadow: 0 16px 42px rgba(0,0,0,.20) !important;
}

html[data-resolved-theme="dark"] body .room-management-card h3,
html[data-resolved-theme="dark"] body .room-management-card p,
html[data-resolved-theme="dark"] body .room-meta,
html[data-resolved-theme="dark"] body .inventory-admin-card,
html[data-resolved-theme="dark"] body .room-management-item-content {
    color: var(--ui-text) !important;
    -webkit-text-fill-color: var(--ui-text) !important;
}

/* Modal information tiles / pills */
html[data-resolved-theme="dark"] body .employee-management-information > div,
html[data-resolved-theme="dark"] body .inventory-modal-information > div,
html[data-resolved-theme="dark"] body .room-item-information > div,
html[data-resolved-theme="dark"] body .room-employee-pill,
html[data-resolved-theme="dark"] body .room-empty-message,
html[data-resolved-theme="dark"] body .employee-picker-no-photo,
html[data-resolved-theme="dark"] body .employee-management-no-photo {
    background: var(--ui-surface-soft) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
    box-shadow: none !important;
}

html[data-resolved-theme="dark"] body .employee-management-information > div span,
html[data-resolved-theme="dark"] body .inventory-modal-information > div span,
html[data-resolved-theme="dark"] body .room-item-information > div span,
html[data-resolved-theme="dark"] body .employee-management-position,
html[data-resolved-theme="dark"] body .room-management-card p {
    color: var(--ui-muted) !important;
    -webkit-text-fill-color: var(--ui-muted) !important;
}

html[data-resolved-theme="dark"] body .employee-management-information > div strong,
html[data-resolved-theme="dark"] body .inventory-modal-information > div strong,
html[data-resolved-theme="dark"] body .room-item-information > div strong,
html[data-resolved-theme="dark"] body .room-employee-pill {
    color: var(--ui-text) !important;
    -webkit-text-fill-color: var(--ui-text) !important;
}

/* Section headings and legacy labels used navy/grey values from the light theme. */
html[data-resolved-theme="dark"] body .room-management-section h3,
html[data-resolved-theme="dark"] body .field label,
html[data-resolved-theme="dark"] body .form-title-row h2,
html[data-resolved-theme="dark"] body .permissions-title,
html[data-resolved-theme="dark"] body .employee-picker-header h3 {
    color: var(--ui-text) !important;
    -webkit-text-fill-color: var(--ui-text) !important;
}

html[data-resolved-theme="dark"] body .form-title-row p,
html[data-resolved-theme="dark"] body .employee-picker-header p,
html[data-resolved-theme="dark"] body .room-management-section > p {
    color: var(--ui-muted) !important;
    -webkit-text-fill-color: var(--ui-muted) !important;
}

/* Pills / badges should belong to the dark surface too. */
html[data-resolved-theme="dark"] body .role-badge,
html[data-resolved-theme="dark"] body .inventory-category-badge {
    background: var(--ui-surface-soft) !important;
    color: var(--ui-text) !important;
    -webkit-text-fill-color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
}

/* Keep primary blue actions blue; only improve their contrast. */
html[data-resolved-theme="dark"] body .primary-button,
html[data-resolved-theme="dark"] body .save-button,
html[data-resolved-theme="dark"] body .header-buttons .primary-button {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}

/* =========================================================
   V9.5.3 — Tenant dark modal text contrast
   ========================================================= */

/* Room-management summary: labels and values must be readable on dark surfaces. */
html[data-resolved-theme="dark"] body .room-management-modal .room-summary-box,
html[data-resolved-theme="dark"] body .room-summary-box {
    background: var(--ui-surface-soft) !important;
    border-color: var(--ui-line) !important;
}

html[data-resolved-theme="dark"] body .room-management-modal .room-summary-box span,
html[data-resolved-theme="dark"] body .room-summary-box span {
    color: #f2f2f7 !important;
    -webkit-text-fill-color: #f2f2f7 !important;
    opacity: 1 !important;
}

html[data-resolved-theme="dark"] body .room-management-modal .room-summary-box strong,
html[data-resolved-theme="dark"] body .room-summary-box strong {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    opacity: 1 !important;
}

/* General legacy modal labels/copy that inherited dark navy or low-contrast grey. */
html[data-resolved-theme="dark"] body .room-management-modal,
html[data-resolved-theme="dark"] body .room-management-modal .modal-title,
html[data-resolved-theme="dark"] body .room-management-modal h1,
html[data-resolved-theme="dark"] body .room-management-modal h2,
html[data-resolved-theme="dark"] body .room-management-modal h3,
html[data-resolved-theme="dark"] body .room-management-modal h4,
html[data-resolved-theme="dark"] body .room-management-modal label {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}

html[data-resolved-theme="dark"] body .room-management-modal .text-muted,
html[data-resolved-theme="dark"] body .room-management-modal .form-text,
html[data-resolved-theme="dark"] body .room-management-modal small,
html[data-resolved-theme="dark"] body .room-management-modal p,
html[data-resolved-theme="dark"] body .room-management-modal .sub,
html[data-resolved-theme="dark"] body .room-management-modal .muted {
    color: #d1d1d6 !important;
    -webkit-text-fill-color: #d1d1d6 !important;
    opacity: 1 !important;
}

/* Keep actual data/value text bright across old information tiles. */
html[data-resolved-theme="dark"] body .room-management-modal .employee-management-information strong,
html[data-resolved-theme="dark"] body .room-management-modal .inventory-modal-information strong,
html[data-resolved-theme="dark"] body .room-management-modal .room-item-information strong {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}

html[data-resolved-theme="dark"] body .room-management-modal .employee-management-information span,
html[data-resolved-theme="dark"] body .room-management-modal .inventory-modal-information span,
html[data-resolved-theme="dark"] body .room-management-modal .room-item-information span {
    color: #d1d1d6 !important;
    -webkit-text-fill-color: #d1d1d6 !important;
    opacity: 1 !important;
}

/* =========================================================
   V9.5.4 — Room card layout / action overflow fix
   ========================================================= */

/*
 * admin.css originally allows room cards down to 260px.
 * With 25px card padding, the usable width can drop to ~210px,
 * which is not enough for 3 Bulgarian action labels in one row.
 */
.rooms-grid {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)) !important;
    align-items: stretch;
}

.room-management-card {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Keep the actions aligned at the bottom of every card. */
.room-management-card .room-buttons {
    margin-top: auto !important;
    padding-top: 15px;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100%;
    min-width: 0;
}

/* The delete action is wrapped in a form, so the form must also shrink. */
.room-management-card .room-buttons > a,
.room-management-card .room-buttons > button,
.room-management-card .room-buttons > form {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100%;
    margin: 0 !important;
}

.room-management-card .room-buttons > form {
    display: block;
}

.room-management-card .room-buttons a,
.room-management-card .room-buttons button {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100%;
    padding: 9px 6px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    line-height: 1.2;
    font-size: 13px;
    box-sizing: border-box;
}

/* Preserve the danger styling but prevent the delete form/button from escaping. */
.room-management-card .room-buttons .room-delete-form,
.room-management-card .room-buttons .room-delete-button {
    min-width: 0 !important;
    width: 100% !important;
}

/* A little more room on narrower screens; then stack naturally on phones. */
@media (max-width: 900px) {
    .rooms-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important;
    }

    .room-management-card .room-buttons a,
    .room-management-card .room-buttons button {
        font-size: 12px;
        padding-left: 5px !important;
        padding-right: 5px !important;
    }
}

@media (max-width: 520px) {
    .rooms-grid {
        grid-template-columns: 1fr !important;
    }

    .room-management-card .room-buttons {
        grid-template-columns: 1fr !important;
    }
}


/* ================================================
   V10.1 — ROOM QR ACTION LAYOUT
   Keep the QR action on its own row.
================================================ */
.room-management-card .room-buttons {
    margin-top: auto !important;
    padding-top: 15px;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100%;
    min-width: 0;
}

.room-management-card .room-buttons .room-buttons-primary {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100%;
    min-width: 0;
}

.room-management-card .room-buttons .room-buttons-primary > a,
.room-management-card .room-buttons .room-buttons-primary > button,
.room-management-card .room-buttons > .room-qr-download-button,
.room-management-card .room-buttons > .room-delete-form {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
}

.room-management-card .room-buttons > .room-qr-download-button {
    display: flex !important;
    align-items: center;
    justify-content: center;
    white-space: normal !important;
}

.room-management-card .room-buttons > .room-delete-form {
    display: block !important;
}
