/* ========================================
   SHARED DIALOG COMPONENTS
   FriendlyNameEditorModal, ActionAuditHistoryDialog, NotificationModal, BatteryHistoryModal, BatteryCommandModal
   (domain content only; the dialog shell itself is styled by frontend-polish.css).
   ======================================== */

/* ---------- Shared/FriendlyNameEditorModal.razor ---------- */
.friendly-name-editor-dialog .e-dlg-content {
    padding: 0;
}

.friendly-name-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
}

.friendly-name-modal-eyebrow {
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.friendly-name-modal-title {
    margin: 0.25rem 0 0;
    color: #f7fafc;
    font-size: 1.1rem;
    font-weight: 700;
}

.friendly-name-history-btn {
    border: 1px solid rgba(var(--color-primary-rgb), 0.28) !important;
    color: var(--color-primary) !important;
}

.friendly-name-editor-body {
    padding: 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.friendly-name-context-card {
    border: 1px solid rgba(var(--color-primary-rgb), 0.2);
    border-radius: 12px;
    background: rgba(var(--color-primary-rgb), 0.08);
    padding: 0.9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.friendly-name-context-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}

.friendly-name-context-label {
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.friendly-name-context-value {
    color: #f7fafc;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.92rem;
    text-align: right;
    word-break: break-all;
}

.friendly-name-field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.friendly-name-field-label {
    color: #f7fafc;
    font-size: 0.88rem;
    font-weight: 600;
}

.friendly-name-field-note {
    color: rgba(255, 255, 255, 0.58);
    font-size: 0.78rem;
}

.friendly-name-history-panel {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.friendly-name-history-header {
    color: #f7fafc;
    font-size: 0.9rem;
    font-weight: 700;
}

.friendly-name-history-loading,
.friendly-name-history-empty {
    min-height: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.58);
    text-align: center;
}

.friendly-name-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    max-height: 15rem;
    overflow-y: auto;
    padding-right: 0.2rem;
}

.friendly-name-history-item {
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.8rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.friendly-name-history-topline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.friendly-name-history-user {
    color: #f7fafc;
    font-size: 0.84rem;
    font-weight: 700;
}

.friendly-name-history-date {
    color: rgba(255, 255, 255, 0.52);
    font-size: 0.77rem;
}

.friendly-name-history-change {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: #dbe7ef;
    font-size: 0.84rem;
    flex-wrap: wrap;
}

.friendly-name-history-change i {
    color: var(--color-primary);
}

.friendly-name-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    width: 100%;
}

@media (max-width: 640px) {
    .friendly-name-context-row,
    .friendly-name-history-topline {
        flex-direction: column;
        align-items: flex-start;
    }

    .friendly-name-context-value {
        text-align: left;
    }

    .friendly-name-modal-actions {
        flex-direction: column-reverse;
    }

    .friendly-name-modal-actions .e-btn {
        width: 100%;
    }
}

/* ---------- Shared/ActionAuditHistoryDialog.razor ---------- */
.audit-content { padding: 1rem; color: #e2e8f0; }
.audit-list { display: grid; gap: .7rem; }
.audit-row { padding: .85rem; border: 1px solid rgba(45,212,191,.28); border-radius: 8px; background: rgba(15,23,42,.72); }
.audit-row-top, .audit-meta, .audit-pagination { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
.audit-row-top { justify-content: space-between; text-transform: capitalize; }
.audit-meta { color: #94a3b8; font-size: .78rem; margin-top: .35rem; }
.audit-target, .audit-result { margin-top: .4rem; overflow-wrap: anywhere; }
.audit-change-summary { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .7rem; color: #cbd5e1; font-size: .82rem; }
.audit-change-summary > span:first-child { margin-right: auto; }
.audit-change-summary i { color: #2dd4bf; margin-right: .25rem; }
.audit-chip { padding: .15rem .5rem; border: 1px solid rgba(45,212,191,.28); border-radius: 999px; color: #99f6e4; background: rgba(13,148,136,.08); font-size: .72rem; text-transform: capitalize; }
.audit-changes { display: grid; gap: .45rem; margin-top: .55rem; }
.audit-change { display: grid; grid-template-columns: minmax(190px, 1fr) minmax(260px, 1.4fr); gap: .75rem; align-items: center; padding: .62rem .7rem; border: 1px solid rgba(148,163,184,.14); border-radius: 7px; background: rgba(15,23,42,.5); }
.audit-change-name { min-width: 0; }
.audit-change-name strong { display: block; color: #e2e8f0; font-size: .83rem; }
.audit-change-section { display: block; color: #67e8f9; font-size: .67rem; letter-spacing: .045em; text-transform: uppercase; margin-bottom: .12rem; }
.audit-change-values { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: .45rem; align-items: center; }
.audit-value { min-width: 0; padding: .28rem .45rem; border-radius: 5px; overflow-wrap: anywhere; font-size: .78rem; }
.audit-value-before { color: #cbd5e1; background: rgba(71,85,105,.25); }
.audit-value-after { color: #a7f3d0; background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.18); }
.audit-change-arrow { color: #64748b; font-size: .7rem; }
.audit-details-message { display: flex; gap: .45rem; align-items: flex-start; margin-top: .65rem; padding: .6rem .7rem; color: #94a3b8; background: rgba(51,65,85,.2); border-radius: 6px; font-size: .78rem; }
.audit-key-values { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: .6rem; }
.audit-key-values > div { display: flex; gap: .35rem; padding: .3rem .5rem; border: 1px solid rgba(148,163,184,.15); border-radius: 5px; font-size: .74rem; }
.audit-key-values span { color: #94a3b8; }
.audit-key-values strong { color: #e2e8f0; font-weight: 600; }
.audit-result { color: #a5f3fc; font-size: .84rem; }
.audit-outcome { padding: .16rem .55rem; border-radius: 999px; background: rgba(71,85,105,.5); font-size: .72rem; }
.audit-acknowledged, .audit-queued { color: #86efac; border: 1px solid rgba(34,197,94,.45); }
.audit-failed, .audit-rejected, .audit-timed_out { color: #fca5a5; border: 1px solid rgba(239,68,68,.45); }
.audit-pagination { justify-content: center; margin-top: 1rem; }
.audit-empty { padding: 2rem; text-align: center; color: #94a3b8; }
@media (max-width: 720px) {
    .audit-change { grid-template-columns: 1fr; gap: .45rem; }
}

/* ---------- Shared/NotificationModal.razor ---------- */
/* Test with simple semi-transparent background */
.notification-modal {
    background: #171b1d !important;
    border: 1px solid rgba(var(--color-primary-rgb), 0.28);
    border-radius: 8px !important;
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(var(--color-primary-rgb), 0.08);
    overflow: hidden;
}

.notification-modal .e-dlg-header,
.notification-modal .lbsa-mobile-dialog-header {
    background: rgba(var(--color-primary-rgb), 0.1) !important;
    border-bottom: 1px solid rgba(var(--color-primary-rgb), 0.24);
    color: rgba(255, 255, 255, 0.96) !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
    padding: 0.95rem 1.15rem !important;
    overflow-wrap: anywhere;
}

.notification-modal .e-dlg-header-content,
.notification-modal .e-dlg-header-content .e-dlg-header,
.notification-modal .lbsa-mobile-dialog-header > * {
    color: rgba(255, 255, 255, 0.96) !important;
}

.notification-modal .e-dlg-content,
.notification-modal .lbsa-mobile-dialog-content {
    background: #171b1d !important;
    color: rgba(255, 255, 255, 0.88) !important;
    padding: 0 !important;
}

.notification-modal .e-dlg-closeicon-btn,
.notification-modal .lbsa-mobile-dialog-close {
    border: 1px solid rgba(var(--color-primary-rgb), 0.28) !important;
    border-radius: 6px !important;
    background: rgba(var(--color-primary-rgb), 0.08) !important;
    color: var(--color-primary) !important;
}

.notification-modal .lbsa-mobile-dialog-close:hover {
    background: rgba(var(--color-primary-rgb), 0.16) !important;
    border-color: rgba(var(--color-primary-rgb), 0.48) !important;
}

.notification-modal .notification-detail {
    padding: 1.35rem 1.45rem 1.25rem;
}

.notification-modal .notification-detail-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.75rem 0.85rem;
    background: rgba(var(--color-primary-rgb), 0.08);
    border: 1px solid rgba(var(--color-primary-rgb), 0.16);
    border-radius: 6px;
}

.notification-modal .notification-detail-type {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: uppercase;
}

.notification-modal .notification-detail-type.error {
    background: rgba(var(--color-danger-rgb), 0.14);
    color: var(--color-danger);
}

.notification-modal .notification-detail-type.success {
    background: rgba(var(--color-success-rgb), 0.14);
    color: var(--color-success);
}

.notification-modal .notification-detail-type.warning {
    background: rgba(var(--color-warning-rgb), 0.14);
    color: var(--color-warning);
}

.notification-modal .notification-detail-type.info {
    background: rgba(var(--color-primary-rgb), 0.16);
    color: var(--color-primary);
}

.notification-modal .notification-detail-date {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.68);
    font-weight: 500;
    text-align: right;
    white-space: nowrap;
}

.notification-modal .notification-detail-content {
    padding: 0.2rem 0 1.15rem;
}

.notification-modal .notification-detail-title {
    margin: 0 0 0.75rem 0;
    font-size: 1.35rem;
    line-height: 1.25;
    font-weight: 600;
    color: var(--color-primary);
    overflow-wrap: anywhere;
}

.notification-modal .notification-detail-body {
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    max-height: 320px;
    overflow-y: auto;
    overflow-wrap: anywhere;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 0.95rem 1rem;
}

.notification-modal .notification-detail-actions {
    display: flex;
    gap: 0.65rem;
    justify-content: flex-end;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid rgba(var(--color-primary-rgb), 0.14);
}

.notification-modal .notification-detail-actions .e-btn {
    min-height: 36px;
    padding: 0.45rem 0.85rem;
    border-radius: 5px;
    font-size: 0.8rem;
}

:where(.notification-modal) .mark-read-btn {
    background: rgba(var(--color-success-rgb), 0.1);
    border: 1px solid rgba(var(--color-success-rgb), 0.3);
    color: var(--color-success);
}

:where(.notification-modal) .mark-read-btn:hover {
    background: rgba(var(--color-success-rgb), 0.2);
    border-color: rgba(var(--color-success-rgb), 0.5);
}

:where(.notification-modal) .mark-unread-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
}

:where(.notification-modal) .mark-unread-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

:where(.notification-modal) .delete-btn {
    background: rgba(var(--color-danger-rgb), 0.1);
    border: 1px solid rgba(var(--color-danger-rgb), 0.3);
    color: var(--color-danger);
}

:where(.notification-modal) .delete-btn:hover {
    background: rgba(var(--color-danger-rgb), 0.2);
    border-color: rgba(var(--color-danger-rgb), 0.5);
}

:where(.notification-modal) .close-btn {
    background: rgba(var(--color-primary-rgb), 0.1);
    border: 1px solid rgba(var(--color-primary-rgb), 0.3);
    color: var(--color-primary);
}

:where(.notification-modal) .close-btn:hover {
    background: rgba(var(--color-primary-rgb), 0.2);
    border-color: rgba(var(--color-primary-rgb), 0.5);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .notification-modal .notification-detail {
        padding: 1rem;
    }

    .notification-modal .notification-detail-actions {
        flex-direction: column;
    }

    .notification-modal .notification-detail-meta {
        flex-direction: column;
        gap: 0.65rem;
        align-items: flex-start;
    }

    .notification-modal .notification-detail-date {
        align-self: flex-end;
        white-space: normal;
    }
}

/* ---------- Shared/BatteryHistoryModal.razor ---------- */
.battery-history-modal,
.history-event-detail-modal,
.history-module-data-modal {
    background: #151a21 !important;
    border: 1px solid rgba(var(--color-primary-rgb), .28) !important;
    border-radius: 14px !important;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .55) !important;
    color: #f3f7fa;
    overflow: hidden;
}

.battery-history-modal .lbsa-mobile-dialog-header,
.history-event-detail-modal .lbsa-mobile-dialog-header,
.history-module-data-modal .lbsa-mobile-dialog-header {
    background: linear-gradient(135deg, #18242d 0%, #11171d 100%);
    border-bottom: 1px solid rgba(var(--color-primary-rgb), .18);
    padding: 14px 52px 14px 18px;
}

.battery-history-modal .lbsa-mobile-dialog-content,
.history-event-detail-modal .lbsa-mobile-dialog-content,
.history-module-data-modal .lbsa-mobile-dialog-content { min-height: 0; overflow: hidden; }

:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-dialog-header { display: flex; align-items: center; gap: 12px; min-width: 0; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-dialog-header > span:last-child { display: flex; flex-direction: column; min-width: 0; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-dialog-header strong { font-size: 1rem; line-height: 1.25; letter-spacing: .01em; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-dialog-header small { color: rgba(255,255,255,.58); line-height: 1.2; overflow-wrap: anywhere; white-space: normal; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-header-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; color: #5ee7f2; background: rgba(var(--color-primary-rgb), .12); }

:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-shell { height: 100%; display: flex; flex-direction: column; min-height: 0; padding: 14px; gap: 10px; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-toolbar { display: flex; align-items: center; justify-content: space-between; color: rgba(255,255,255,.68); font-size: .82rem; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-toolbar strong { color: #fff; margin-right: 4px; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-last-log { display: flex; align-items: center; gap: 6px; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-last-log i { color: #37d89b; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-table-header, :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-log-row { display: grid; grid-template-columns: 165px minmax(220px, 1.7fr) 125px minmax(250px, 1fr) 24px; align-items: center; gap: 12px; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-table-header { padding: 0 14px 8px; color: rgba(255,255,255,.48); font-size: .69rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-log-viewport { position: relative; flex: 1; min-height: 0; overflow-y: auto; scrollbar-color: rgba(var(--color-primary-rgb), .45) transparent; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-log-row { min-height: 68px; margin-bottom: 5px; padding: 9px 14px; background: rgba(255,255,255,.035); border: 1px solid rgba(255,255,255,.07); border-left: 3px solid rgba(var(--color-primary-rgb), .55); border-radius: 9px; cursor: pointer; transition: border-color .15s ease, background .15s ease, transform .15s ease; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-log-row:hover, :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-log-row:focus-visible { background: rgba(var(--color-primary-rgb), .08); border-color: rgba(var(--color-primary-rgb), .38); outline: none; transform: translateY(-1px); }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-log-row.severity-error { border-left-color: #ff667a; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-log-row.severity-warning { border-left-color: #f4c65d; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-time { display: flex; flex-direction: column; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-time strong { font-size: .88rem; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-time span, :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-time small { color: rgba(255,255,255,.5); font-size: .7rem; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-event { display: flex; gap: 10px; align-items: center; min-width: 0; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-event i { color: #5ee7f2; width: 18px; text-align: center; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-event span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .84rem; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-meta small { color: rgba(255,255,255,.5); }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-status { display: inline-flex; border-radius: 999px; padding: 3px 8px; font-size: .68rem; font-weight: 700; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .status-success { color: #75e7bb; background: rgba(55,216,155,.12); }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .status-warning { color: #f4cf78; background: rgba(244,198,93,.12); }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .status-danger { color: #ff8d9c; background: rgba(255,102,122,.12); }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .status-neutral { color: #c5ced6; background: rgba(197,206,214,.1); }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-stats { display: grid; grid-template-columns: repeat(3, minmax(72px, 1fr)); gap: 7px; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-stats span { color: #eef5f8; font-size: .78rem; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-stats small { display: block; color: rgba(255,255,255,.42); font-size: .62rem; text-transform: uppercase; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-action { color: rgba(255,255,255,.35); }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-skeleton { height: 68px; margin-bottom: 5px; border-radius: 9px; background: linear-gradient(90deg, rgba(255,255,255,.035), rgba(255,255,255,.08), rgba(255,255,255,.035)); background-size: 200% 100%; animation: history-shimmer 1.3s infinite; }
@keyframes history-shimmer { to { background-position: -200% 0; } }

:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-empty-state, :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-loading-state { height: 100%; min-height: 210px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; color: rgba(255,255,255,.55); text-align: center; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-empty-state i { font-size: 2rem; color: rgba(var(--color-primary-rgb), .7); }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-empty-state strong { color: #f2f6f8; }

:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .event-detail-scroll, :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .module-detail-shell { height: 100%; overflow-y: auto; padding: 14px; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .event-hero { padding: 16px; border-radius: 11px; background: linear-gradient(135deg, rgba(var(--color-primary-rgb), .12), rgba(var(--color-primary-rgb), .035)); border: 1px solid rgba(var(--color-primary-rgb), .2); }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .event-hero.severity-error { border-color: rgba(255,102,122,.35); background: linear-gradient(135deg, rgba(255,102,122,.12), rgba(255,102,122,.025)); }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .event-hero.severity-warning { border-color: rgba(244,198,93,.35); background: linear-gradient(135deg, rgba(244,198,93,.12), rgba(244,198,93,.025)); }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .event-hero h3 { margin: 10px 0 5px; font-size: 1.05rem; line-height: 1.4; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .event-hero p { margin: 0; color: rgba(255,255,255,.6); font-size: .8rem; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .event-error-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .event-error-list span { display: inline-flex; gap: 6px; align-items: center; color: #ff9aa7; background: rgba(255,102,122,.1); border-radius: 7px; padding: 6px 8px; font-size: .76rem; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .event-detail-lines { margin: 12px 0 0; padding-left: 18px; color: var(--text-secondary); font-size: .8rem; line-height: 1.45; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .detail-section-card { margin-top: 12px; padding: 14px; border: 1px solid rgba(255,255,255,.075); border-radius: 10px; background: rgba(255,255,255,.025); }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .detail-section-card h4 { margin: 0 0 12px; color: #5ee7f2; font-size: .76rem; letter-spacing: .07em; text-transform: uppercase; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .detail-section-card h4 i { margin-right: 6px; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .detail-metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .detail-metric-grid-four { grid-template-columns: repeat(4, minmax(0,1fr)); }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .detail-metric { padding: 9px; border-radius: 8px; background: rgba(255,255,255,.035); min-width: 0; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .detail-metric span { display: block; color: rgba(255,255,255,.46); font-size: .66rem; margin-bottom: 3px; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .detail-metric strong { display: block; font-size: .82rem; overflow-wrap: anywhere; }

:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-modal-actions { width: 100%; display: flex; justify-content: flex-end; gap: 8px; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-primary-button, :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-secondary-button { border-radius: 8px; padding: 8px 13px; font-weight: 700; font-size: .78rem; cursor: pointer; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-primary-button { color: #061316; border: 1px solid #5ee7f2; background: #5ee7f2; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-secondary-button { color: #e8eef2; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.055); }

:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .module-detail-shell { display: flex; flex-direction: column; gap: 12px; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .module-summary-bar { display: flex; justify-content: space-between; gap: 12px; color: rgba(255,255,255,.62); font-size: .78rem; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .module-summary-bar i { margin-right: 6px; color: #5ee7f2; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .module-card-list { display: grid; gap: 12px; }
.history-module-data-modal .module-card { max-height: none; border: 1px solid rgba(255,255,255,.08); border-radius: 11px; background: rgba(255,255,255,.025); overflow: hidden; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .module-card-header { display: flex; align-items: center; gap: 20px; padding: 11px 13px; background: rgba(var(--color-primary-rgb), .055); border-bottom: 1px solid rgba(var(--color-primary-rgb), .12); }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .module-card-header > div:first-child { display: flex; align-items: baseline; gap: 7px; color: rgba(255,255,255,.5); font-size: .72rem; text-transform: uppercase; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .module-card-header > div:first-child strong { color: #5ee7f2; font-size: 1.12rem; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .module-card-summary { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .module-card-summary span { font-size: .76rem; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .module-card-summary small { display: block; color: rgba(255,255,255,.42); font-size: .62rem; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .cell-voltage-grid { display: grid; grid-template-columns: repeat(12, minmax(58px,1fr)); gap: 1px; background: rgba(255,255,255,.06); }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .cell-voltage { display: grid; grid-template-columns: 1fr auto; align-items: baseline; padding: 10px 7px; background: #171d24; text-align: center; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .cell-voltage span { grid-column: 1 / -1; color: rgba(255,255,255,.42); font-size: .62rem; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .cell-voltage strong { font-size: .8rem; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .cell-voltage small { color: rgba(255,255,255,.42); font-size: .55rem; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .cell-voltage.cell-low strong { color: #f4c65d; }
:where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .cell-voltage.cell-high strong { color: #5ee7f2; }

@media (max-width: 768px) {
    .battery-history-modal, .history-event-detail-modal, .history-module-data-modal { width: 100vw !important; height: 100dvh !important; max-width: none !important; max-height: none !important; border: 0 !important; border-radius: 0 !important; }
    .battery-history-modal .lbsa-mobile-dialog-header, .history-event-detail-modal .lbsa-mobile-dialog-header, .history-module-data-modal .lbsa-mobile-dialog-header { padding: 10px 46px 10px 12px; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-header-icon { width: 30px; height: 30px; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-shell { padding: 8px; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-table-header { grid-template-columns: 104px minmax(0,1fr) 18px; gap: 8px; padding: 0 9px 6px; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-table-header span:nth-child(3), :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-table-header span:nth-child(4) { display: none; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-log-row { grid-template-columns: 104px minmax(0,1fr) 18px; gap: 8px; min-height: 72px; padding: 8px 9px; margin-bottom: 4px; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-meta, :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-stats { display: none; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-time strong { font-size: .79rem; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-time span { font-size: .63rem; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-log-number { display: none; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-event { gap: 7px; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-event span { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: .78rem; line-height: 1.3; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-row-action { font-size: .7rem; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-toolbar { padding: 0 2px; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-last-log { font-size: .72rem; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .event-detail-scroll, :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .module-detail-shell { padding: 9px; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .detail-metric-grid, :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .detail-metric-grid-four { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 6px; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .detail-section-card { padding: 10px; margin-top: 8px; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-modal-actions { justify-content: stretch; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-primary-button, :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .history-secondary-button { flex: 1; min-height: 44px; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .module-summary-bar { flex-direction: column; gap: 4px; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .module-card-header { align-items: flex-start; gap: 10px; padding: 9px; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .module-card-summary { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .cell-voltage-grid { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 1px; }
    :where(.battery-history-modal, .history-event-detail-modal, .history-module-data-modal) .cell-voltage { padding: 9px 8px; }
}

/* ---------- Shared/BatteryCommandModal.razor ---------- */
/* Former inline <style> block. Every rule is scoped under the dialog's root class so the former
   body-order tie-wins (over frontend-polish.css and user-sessions.css) now hold on specificity.
   The MobileDialog shell owns the header/footer chrome and the backdrop. */
.lbsa-mobile-dialog.battery-command-dialog {
    border: 1px solid rgba(var(--color-primary-rgb), 0.2);
    box-shadow: 0 0 20px rgba(var(--color-primary-rgb), 0.1);
}

.battery-command-dialog .dialog-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--color-primary);
    font-size: 1.25rem;
    font-weight: 400;
}

.battery-command-dialog .command-content {
    padding: 1rem 0;
}

.battery-command-dialog .command-description {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.battery-command-dialog .warning-box {
    background: rgba(var(--color-danger-rgb), 0.1);
    border: 1px solid rgba(var(--color-danger-rgb), 0.3);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    margin: 1rem 0;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    color: var(--color-danger);
}

.battery-command-dialog .warning-box i {
    font-size: 1.25rem;
    margin-top: 2px;
}

.battery-command-dialog .warning-box p {
    margin: 0;
    color: var(--text-primary);
}

.battery-command-dialog .shutdown-warning-box {
    background: rgba(var(--color-warning-rgb), 0.1);
    border: 1px solid rgba(var(--color-warning-rgb), 0.3);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    margin: 1rem 0;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    color: var(--color-warning);
}

.battery-command-dialog .shutdown-warning-box i {
    font-size: 1.25rem;
    margin-top: 2px;
}

.battery-command-dialog .shutdown-warning-box p {
    margin: 0;
    color: var(--text-primary);
}

.battery-command-dialog .emergency-stop-warning-box {
    background: rgba(var(--color-danger-rgb), 0.15);
    border: 2px solid rgba(var(--color-danger-rgb), 0.5);
    border-radius: 6px;
    padding: 1.25rem;
    margin: 1rem 0;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    color: var(--color-danger);
    animation: battery-command-pulse-warning 2s ease-in-out infinite;
}

.battery-command-dialog .emergency-stop-warning-box i {
    font-size: 1.5rem;
    margin-top: 2px;
    color: var(--color-danger);
}

.battery-command-dialog .emergency-stop-warning-box p {
    margin: 0;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    line-height: 1.4;
}

@keyframes battery-command-pulse-warning {
    0%, 100% { border-color: rgba(var(--color-danger-rgb), 0.5); }
    50% { border-color: rgba(var(--color-danger-rgb), 0.8); }
}

.battery-command-dialog .battery-info {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.battery-command-dialog .battery-info label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.battery-command-dialog .battery-info span {
    color: var(--color-primary);
    font-weight: 500;
}

.battery-command-dialog .processing-container {
    text-align: center;
    padding: 2rem 0;
}

.battery-command-dialog .processing-container p {
    margin-top: 1rem;
    color: var(--text-primary);
}

.battery-command-dialog .retry-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.battery-command-dialog .result-success,
.battery-command-dialog .result-error {
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.battery-command-dialog .result-success {
    background: rgba(var(--color-success-rgb), 0.1);
    border: 1px solid rgba(var(--color-success-rgb), 0.3);
    color: var(--color-success);
}

.battery-command-dialog .result-error {
    background: rgba(var(--color-danger-rgb), 0.1);
    border: 1px solid rgba(var(--color-danger-rgb), 0.3);
    color: var(--color-danger);
}

.battery-command-dialog .result-success p,
.battery-command-dialog .result-error p {
    margin: 0;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1rem;
}

.battery-command-dialog .result-success i {
    font-size: 1.25rem;
    color: var(--color-success);
}

.battery-command-dialog .result-error i {
    font-size: 1.25rem;
    color: var(--color-danger);
}

/* The shell's footer rule zeroes padding on .dialog-footer, so only the layout survives from the block. */
.battery-command-dialog .dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Battery firmware dialog (BatteryCard): the battery USB drive ZIP this Slave bootloader needs,
   one line under the Slave version, for users who can download the ZIPs. Kept here while
   battery-card.css is over the size limit; live-monitor.css makes .current-version a flex row. */
.firmware-info-grid .current-version:has(> .firmware-usb-drive-hint) {
    flex-wrap: wrap;
}

.firmware-info-grid .current-version > .firmware-usb-drive-hint {
    flex-basis: 100%;
    font-size: 0.72rem;
    font-weight: 300;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
}
