:root {
    /* Light Theme (Default) */
    --bg-color: #f0f2f5;
    --bg-image: none;
    --panel-bg: rgba(255, 255, 255, 0.95);
    --border-color: #d9d9d9;
    --text-primary: #333333;
    --text-secondary: #666666;
    --accent-color: #1890ff;
    --success-color: #52c41a;
    --warning-color: #faad14;
    --danger-color: #f5222d;
    --glow-shadow: none;
    --header-bg: rgba(255, 255, 255, 0.95);
    --item-hover-bg: rgba(0, 0, 0, 0.05);
    --item-active-bg: rgba(24, 144, 255, 0.1);
    --input-bg: rgba(0, 0, 0, 0.05);
    --input-color: #333;
    --scrollbar-track: #f0f0f0;
    --scrollbar-thumb: #ccc;

    --chart-bg: rgba(0, 0, 0, 0.02);
}

body.theme-dark {
    /* Dark Theme */
    --bg-color: #050b14;
    --bg-image: radial-gradient(circle at 50% 50%, #0d1a2f 0%, #050b14 100%);
    --panel-bg: rgba(16, 33, 56, 0.8);
    --border-color: rgba(64, 169, 255, 0.3);
    --text-primary: #e6f7ff;
    --text-secondary: #90a0b0;
    --accent-color: #1890ff;
    --success-color: #52c41a;
    --warning-color: #faad14;
    --danger-color: #f5222d;
    --glow-shadow: 0 0 10px rgba(24, 144, 255, 0.5);
    --header-bg: rgba(5, 11, 20, 0.9);
    --item-hover-bg: rgba(255, 255, 255, 0.1);
    --item-active-bg: rgba(24, 144, 255, 0.15);
    --input-bg: rgba(0, 0, 0, 0.3);
    --input-color: white;
    --scrollbar-track: #000;
    --scrollbar-thumb: #333;

    --chart-bg: rgba(0, 0, 0, 0.2);
}

body.monitor-body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    background-image: var(--bg-image);
    color: var(--text-primary);
    font-family: 'Inter', 'Segoe UI', sans-serif;
    overflow: hidden;
    height: 100vh;
    transition: background 0.3s, color 0.3s;
}

.monitor-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header */
.monitor-header {
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    z-index: 100;
    transition: background 0.3s;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.monitor-header h1 {
    font-size: 1.5rem;
    margin: 0;
    text-shadow: var(--glow-shadow);
    background: linear-gradient(90deg, #1890ff, #00d9ff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-center {
    display: flex;
    gap: 30px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-box .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.stat-box .value {
    font-size: 1.2rem;
    font-weight: bold;
}

.stat-box .value.success {
    color: var(--success-color);
    text-shadow: 0 0 5px var(--success-color);
}

.stat-box .value.danger {
    color: var(--danger-color);
    text-shadow: 0 0 5px var(--danger-color);
}

/* Theme Toggle & Back Button */
.btn-theme {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s;
}

.btn-theme:hover {
    background: var(--item-hover-bg);
}

.btn-back {
    color: var(--accent-color);
    text-decoration: none;
    border: 1px solid var(--accent-color);
    padding: 5px 15px;
    border-radius: 4px;
    transition: all 0.3s;
}

.btn-back:hover {
    background: var(--accent-color);
    color: white;
    box-shadow: var(--glow-shadow);
}

/* Main Layout */
.monitor-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: background 0.3s, border-color 0.3s;
}

.left-panel {
    width: 300px;
    border-right: 1px solid var(--border-color);
}

.left-panel {
    width: 300px;
    border-right: 1px solid var(--border-color);
}

.right-panel {
    width: 350px;
    border-left: 1px solid var(--border-color);
}

.panel-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--accent-color);
}

/* Device List */
.device-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.device-group-header {
    margin: 12px 2px 8px;
    font-size: 12px;
    color: var(--text-secondary);
    letter-spacing: 0.06em;
}

.device-group {
    margin-bottom: 10px;
}

.drag-handle {
    display: inline-block;
    width: 16px;
    margin-right: 6px;
    color: var(--text-secondary);
    cursor: grab;
    user-select: none;
}

#device-search {
    width: 90%;
    margin-top: 10px;
    padding: 5px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--input-color);
}

.device-item {
    padding: 10px;
    margin-bottom: 8px;
    background: var(--item-hover-bg);
    /* Use hover bg as base for item card */
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 4px;
    /* Soften edges in light mode */
}

.device-item:hover {
    background: var(--item-active-bg);
}

.device-item.active {
    background: var(--item-active-bg);
    border-left-color: var(--accent-color);
}

.device-item .d-id {
    font-weight: bold;
    font-size: 0.95rem;
}

.device-item .d-status {
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
}

.device-menu-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    line-height: 16px;
    padding: 0 4px;
    margin-left: 6px;
}

.device-menu-btn:hover {
    color: var(--accent-color);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
}

.status-dot.online {
    background: var(--success-color);
    box-shadow: 0 0 5px var(--success-color);
}

.status-dot.offline {
    background: var(--text-secondary);
}

.status-dot.alarm {
    background: var(--danger-color);
    box-shadow: 0 0 5px var(--danger-color);
}

/* Detail Panel */
.panel-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.detail-content {
    padding: 15px;
    flex: 1;
    overflow-y: auto;
}

.detail-row {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--text-secondary);
    flex: 0 0 92px;
}

.detail-val {
    font-family: monospace;
    font-weight: 500;
    flex: 1;
    min-width: 0;
    text-align: right;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.detail-row-stacked {
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
}

.detail-row-stacked .detail-val {
    text-align: left;
}

.detail-section-title {
    margin-top: 20px;
    border-bottom: none;
    padding-bottom: 0;
}

.detail-val-block {
    text-align: left;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 10px;
    line-height: 1.35;
    white-space: pre-wrap;
    font-size: 12px;
}

.signal-pill {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 20px;
    white-space: nowrap;
}

.charts-container {
    display: flex;
    height: 140px;
    border-top: 1px solid var(--border-color);
    padding-top: 5px;
    background: var(--chart-bg);
}

/* Alarm List */
.alarm-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.alarm-item {
    padding: 10px;
    background: rgba(245, 34, 45, 0.1);
    border: 1px solid rgba(245, 34, 45, 0.3);
    margin-bottom: 8px;
    border-radius: 4px;
    animation: flash 2s infinite;
}

@keyframes flash {
    0% {
        border-color: rgba(245, 34, 45, 0.3);
    }

    50% {
        border-color: rgba(245, 34, 45, 0.8);
    }

    100% {
        border-color: rgba(245, 34, 45, 0.3);
    }
}

.alarm-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.alarm-msg {
    color: var(--danger-color);
    font-weight: bold;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Context Menu */
.context-menu {
    position: absolute;
    z-index: 1000;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 5px 0;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    min-width: 120px;
}

body.theme-dark .context-menu {
    background: var(--panel-bg);
    border-color: var(--border-color);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.context-menu-item {
    padding: 8px 15px;
    font-size: 14px;
    color: var(--text-primary);
    transition: background 0.2s;
}

.context-menu-item:hover {
    background: var(--item-hover-bg);
    color: var(--accent-color);
}

.context-menu-item.danger {
    color: #f5222d;
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
    padding-top: 10px;
}

/* SSH Console Modal */
.ssh-console {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    min-height: 0;
    flex: 1;
}

.ssh-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.ssh-status {
    font-size: 12px;
    color: var(--text-secondary);
    flex: 1;
}

.ssh-output {
    flex: 1 1 auto;
    min-height: 200px;
    max-height: 50vh;
    background: rgba(0, 0, 0, 0.6);
    color: #e8f5ff;
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 6px;
    padding: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    overflow-y: auto;
    overflow-x: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 255, 255, 0.3) rgba(0, 0, 0, 0.2);
}

.ssh-output::-webkit-scrollbar {
    width: 8px;
}

.ssh-output::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.ssh-output::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 255, 0.3);
    border-radius: 4px;
}

.ssh-output::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 255, 255, 0.5);
}

.ssh-upload-panel {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 255, 255, 0.15);
    border-radius: 6px;
    padding: 10px;
    flex-shrink: 0;
}

.ssh-upload-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.ssh-file-input {
    flex: 0 0 auto;
    color: #e8f5ff;
    font-size: 12px;
}

.ssh-file-input::file-selector-button {
    background: rgba(24, 144, 255, 0.2);
    border: 1px solid rgba(24, 144, 255, 0.4);
    color: #58d9f9;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-right: 8px;
}

.ssh-file-input::file-selector-button:hover {
    background: rgba(24, 144, 255, 0.3);
}

.ssh-target-input {
    flex: 1;
    min-width: 180px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 255, 0.2);
    color: #e8f5ff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
}

.ssh-target-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.ssh-select {
    flex: 0 0 auto;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 255, 0.2);
    color: #e8f5ff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    min-width: 100px;
}

.ssh-select:focus {
    outline: none;
    border-color: rgba(0, 255, 255, 0.5);
}

.ssh-upload-status {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    min-height: 16px;
}

.ssh-input-row {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.ssh-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 255, 0.2);
    color: #e8f5ff;
    padding: 8px 10px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
}

.ssh-btn {
    background: #1890ff;
    color: #fff;
    border: 1px solid #1890ff;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
}

.ssh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ssh-btn.secondary {
    background: #444;
    border-color: #444;
}

.theme-light .ssh-output {
    background: #0b1220;
    color: #e8f5ff;
}

.theme-light .ssh-input {
    background: #111827;
    color: #e8f5ff;
    border-color: #2b3a55;
}

.theme-light .ssh-upload-panel {
    background: #f0f2f5;
    border-color: #d9d9d9;
}

.theme-light .ssh-file-input {
    color: #333;
}

.theme-light .ssh-file-input::file-selector-button {
    background: #e6f7ff;
    border-color: #1890ff;
    color: #1890ff;
}

.theme-light .ssh-target-input {
    background: #fff;
    color: #333;
    border-color: #d9d9d9;
}

.theme-light .ssh-target-input::placeholder {
    color: #999;
}

.theme-light .ssh-select {
    background: #fff;
    color: #333;
    border-color: #d9d9d9;
}

.context-menu-item.danger:hover {
    background: rgba(245, 34, 45, 0.08);
    color: #cf1322;
}



/* UI-PRO-MAX Modal System */
.app-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-modal * {
    box-sizing: border-box;
}

.app-modal-content {
    background: linear-gradient(145deg, rgba(20, 25, 35, 0.95), rgba(10, 15, 25, 0.95));
    border: 1px solid rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.1), inset 0 0 10px rgba(0, 255, 255, 0.05);
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-modal-header {
    padding: 18px 25px;
    border-bottom: 1px solid rgba(0, 255, 255, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 255, 255, 0.05);
}

.app-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #0ff;
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.5);
    letter-spacing: 1px;
}

.app-modal-close {
    font-size: 24px;
    line-height: 24px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.5);
    transition: color 0.2s, transform 0.2s;
}

.app-modal-close:hover {
    color: #ff4d4f;
    transform: scale(1.1);
}

.app-modal-body {
    padding: 20px 25px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

/* Modal Search Filters */
.modal-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.modal-filter-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 255, 0.2);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.2s;
}

.modal-filter-input:focus {
    border-color: rgba(0, 255, 255, 0.8);
}

.theme-light .modal-filter-input {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
    border-color: #ddd;
}

.theme-light .modal-filter-input:focus {
    border-color: #1890ff;
}

/* UI-PRO-MAX List Items */
.pro-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding-right: 5px;
}

.pro-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.pro-list-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(0, 255, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.1);
}

.pro-list-item.alarm {
    border-left: 4px solid #ff4d4f;
}

.pro-list-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.pro-list-time {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    font-family: monospace;
}

.pro-list-device {
    font-size: 16px;
    color: #fff;
    font-weight: bold;
}

.pro-list-badge {
    padding: 6px 12px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 14px;
    font-weight: bold;
    background: rgba(255, 77, 79, 0.15);
    color: #ff4d4f;
    border: 1px solid rgba(255, 77, 79, 0.3);
}

.theme-light .app-modal {
    background: rgba(0, 0, 0, 0.45);
}

.theme-light .app-modal-content {
    background: #fff;
    border: 1px solid #e0e0e0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.theme-light .app-modal-header {
    background: linear-gradient(135deg, #f8fafc, #eef2f6);
    border-bottom: 1px solid #e0e4e8;
}

.theme-light .app-modal-header h3 {
    color: #1a1a2e;
    text-shadow: none;
    font-weight: 600;
}

.theme-light .app-modal-close {
    color: #999;
}

.theme-light .app-modal-close:hover {
    color: #ff4d4f;
}

.theme-light .app-modal-body {
    background: #fafbfc;
}

.theme-light .pro-list-item {
    background: #fff;
    border: 1px solid #e8ecf0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border-radius: 8px;
}

.theme-light .pro-list-item:hover {
    background: #f0f7ff;
    border-color: #1890ff;
    box-shadow: 0 4px 16px rgba(24, 144, 255, 0.12);
    transform: translateY(-1px);
}

.theme-light .pro-list-item.alarm {
    border-left: 4px solid #ff4d4f;
    background: #fff5f5;
}

.theme-light .pro-list-item.alarm:hover {
    background: #fff0f0;
    border-color: #ff4d4f;
    box-shadow: 0 4px 16px rgba(255, 77, 79, 0.12);
}

.theme-light .pro-list-device {
    color: #1a1a2e;
}

.theme-light .pro-list-time {
    color: #8c8c8c;
}

.theme-light .pro-list-badge {
    background: rgba(255, 77, 79, 0.08);
    color: #cf1322;
    border-color: rgba(255, 77, 79, 0.25);
}

/* All-alarms modal (ack UI) */
.aa-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    margin-bottom: 12px;
}

.aa-toolbar-left,
.aa-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.aa-toolbar-mid {
    flex: 1;
    min-width: 180px;
}

.aa-toolbar .btn-primary {
    padding: 6px 12px;
    font-size: 13px;
    line-height: 16px;
}

.aa-btn-muted {
    background: #444;
    border-color: #444;
}

.aa-btn-ack {
    background: #8b5a00;
    border-color: #8b5a00;
}

.aa-note {
    width: 100%;
    height: 34px;
}

.aa-list {
    flex: 1;
    overflow: auto;
    padding-right: 6px;
}

.aa-alarm-item {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-radius: 12px;
}

.aa-alarm-item .aa-top {
    display: grid;
    grid-template-columns: 1fr auto 22px;
    align-items: center;
    gap: 10px;
}

.aa-device {
    font-size: 15px;
    font-weight: 700;
}

.aa-time {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.aa-check {
    text-align: right;
    font-weight: 900;
    color: rgba(24, 144, 255, 0.95);
}

.aa-bottom {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.aa-code {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    font-weight: 800;
    background: rgba(255, 77, 79, 0.15);
    color: #ff4d4f;
    border: 1px solid rgba(255, 77, 79, 0.28);
}

.aa-desc {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.78);
    word-break: break-word;
}

.aa-alarm-item.aa-selected {
    background: rgba(24, 144, 255, 0.16) !important;
    border-color: rgba(24, 144, 255, 0.55) !important;
    box-shadow: 0 6px 18px rgba(24, 144, 255, 0.15);
}

.aa-alarm-item.aa-selected .aa-code {
    background: rgba(24, 144, 255, 0.16);
    color: #1890ff;
    border-color: rgba(24, 144, 255, 0.35);
}

.theme-light .aa-toolbar {
    border-bottom-color: #eef2f6;
}

.theme-light .aa-btn-muted {
    background: #2f2f2f;
    border-color: #2f2f2f;
}

.theme-light .aa-time {
    color: #8c8c8c;
}

.theme-light .aa-desc {
    color: #444;
}

.theme-light .aa-alarm-item.aa-selected .aa-desc {
    color: #1a1a2e;
}

.theme-light .aa-alarm-item.aa-selected .aa-check {
    color: #1890ff;
}

/* Historical alarms table */
.table-wrapper {
    overflow: auto;
    flex: 1;
}

.hist-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.hist-table thead th {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    text-align: left;
    padding: 8px 10px;
}

.hist-table tbody td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px 10px;
}

.hist-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.15);
}

.hist-table td.mono {
    font-family: monospace;
}

.theme-light .hist-table thead th {
    background: #f7f9fc;
    border-bottom-color: #e8ecf0;
}

.theme-light .hist-table tbody td {
    border-bottom-color: #eef2f6;
}

.theme-light .hist-table tbody tr:hover {
    background: #f5faff;
}

/* ntfy Chat Styles */
#nc-list {
    background: rgba(0, 0, 0, 0.2);
    padding: 5px;
}

#nc-list div {
    font-size: 13px;
    line-height: 1.5;
}

#nc-msg {
    transition: border-color 0.2s, box-shadow 0.2s;
}

#nc-msg:focus {
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.2);
}

#nc-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
}

#nc-upload-btn:hover {
    background: #555 !important;
    transform: scale(1.05);
}

#nc-status {
    font-size: 12px;
    font-weight: 500;
}

.theme-light #nc-list {
    background: #fafafa;
    border-color: #eee;
}

.theme-light #nc-list div {
    color: #333 !important;
    border-bottom-color: #eee !important;
}

.theme-light #nc-status {
    color: #666;
}

/* ============================================
   底部告警栏样式 - Alarm Bar
   ============================================ */

/* 固定左右边栏宽度 */
.left-panel {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.right-panel {
    width: 320px;
    min-width: 320px;
    max-width: 320px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 地图区域布局 */
.center-panel {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

body.theme-dark .center-panel {
    background: #000;
}

#map-container {
    flex: 1;
    position: relative;
    min-height: 0;
}

/* 底部告警栏 - 在地图区域内 */
.alarm-bar {
    height: 200px;
    min-height: 200px;
    max-height: 200px;
    border-top: 2px solid var(--accent-color);
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    margin: 0;
    position: relative;
    z-index: 100;
    background: var(--panel-bg) !important;
    border-radius: 0;
}

.alarm-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    border-bottom: 1px solid var(--border-color);
    background: var(--panel-bg);
    flex-shrink: 0;
}

.alarm-bar-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.alarm-bar-title h2 {
    margin: 0;
    font-size: 14px;
    color: var(--accent-color);
}

.alarm-count-badge {
    background: var(--danger-color);
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.alarm-bar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-sm {
    font-size: 11px !important;
    padding: 3px 8px !important;
    cursor: pointer;
    border-radius: 3px;
}

.btn-primary {
    background: var(--accent-color);
    color: #fff;
    border: 1px solid var(--accent-color);
    transition: all 0.2s;
}

.btn-primary:hover {
    opacity: 0.85;
}

.alarm-bar-divider {
    width: 1px;
    height: 16px;
    background: var(--border-color);
    margin: 0 4px;
}

.page-indicator {
    font-size: 11px;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: center;
    font-family: monospace;
}

/* 告警表格头 */
.alarm-bar-table-head {
    display: grid;
    grid-template-columns: 30px 40px 140px 50px 140px 1fr 130px 130px;
    padding: 6px 8px;
    background: var(--item-hover-bg);
    border-bottom: 1px solid var(--border-color);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.alarm-bar-table-head > div {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 告警列表 */
.alarm-bar-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--panel-bg);
}

/* 告警行 */
.alarm-row {
    display: grid;
    grid-template-columns: 30px 40px 140px 50px 140px 1fr 130px 130px;
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    transition: background 0.15s;
    align-items: center;
}

.alarm-row > div {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.alarm-row:hover {
    background: var(--item-hover-bg);
}

.alarm-row.active {
    background: rgba(245, 34, 45, 0.08);
    border-left: 3px solid var(--danger-color);
}

.alarm-row.acked {
    opacity: 0.6;
}

/* 各列样式 - 只应用到数据行 */
.alarm-row .col-check {
    text-align: center;
}

.alarm-row .col-check input,
#alarm-check-all-row {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.alarm-row .col-status {
    text-align: center;
}

.alarm-row .col-device {
    font-family: monospace;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.alarm-row .col-count {
    text-align: center;
    font-weight: 600;
    color: var(--danger-color);
}

.alarm-row .col-code {
    font-family: monospace;
    font-weight: 500;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-desc {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-start,
.col-latest {
    font-family: monospace;
    font-size: 11px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 状态指示器 */
.status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-indicator.active {
    background: var(--danger-color);
    box-shadow: 0 0 6px var(--danger-color);
}

.status-indicator.acked {
    background: var(--warning-color);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 空状态 */
.alarm-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    font-size: 13px;
}

/* 告警详情表格 */
.alarm-detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.alarm-detail-table thead th {
    background: var(--item-hover-bg);
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
}

.alarm-detail-table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.alarm-detail-table tbody tr:hover {
    background: var(--item-hover-bg);
}

.alarm-detail-table .mono {
    font-family: monospace;
    font-size: 12px;
}

.alarm-detail-table .alarm-check {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.alarm-detail-table #alarm-check-all {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* 修复设备列表滚动 */
.device-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
}

/* 修复右侧详情面板 */
.detail-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
}

/* Light theme adjustments */
.theme-light .alarm-bar {
    background: var(--panel-bg);
}

.theme-light .alarm-bar-table-head {
    background: #f5f7fa;
}

.theme-light .alarm-row.active {
    background: rgba(245, 34, 45, 0.05);
}

/* 暗色主题 */
.theme-dark .alarm-bar {
    background: rgba(10, 20, 35, 0.95);
}

.theme-dark .alarm-bar-table-head {
    background: rgba(0, 0, 0, 0.2);
}

.theme-dark .alarm-row.active {
    background: rgba(245, 34, 45, 0.12);
}

/* 移动端响应式 */
@media (max-width: 1200px) {
    .alarm-bar-table-head,
    .alarm-row {
        grid-template-columns: 30px 40px 140px 50px 140px 1fr 130px 130px;
        padding: 6px 10px;
    }

    .col-desc {
        max-width: 200px;
    }
}

@media (max-width: 768px) {
    .center-panel {
        display: none !important;
    }

    .monitor-main {
        flex-direction: column;
        overflow-y: auto;
    }

    .left-panel,
    .right-panel {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        flex: none;
        border-left: none;
        border-right: none;
    }

    .left-panel {
        min-height: 50vh;
        border-bottom: 2px solid var(--border-color);
    }

    .right-panel {
        min-height: 50vh;
    }

    .header-center {
        display: none;
    }

    .monitor-header {
        padding: 0 10px;
    }

    .monitor-header h1 {
        font-size: 1.1rem;
    }

    .panel-header {
        padding: 10px;
    }
}

/* 全部告警弹窗列表样式 */
.alarm-modal-table-head {
    display: grid;
    grid-template-columns: 30px 40px 140px 120px 1fr 140px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid var(--border-color);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.alarm-modal-table-head > div {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.alarm-modal-table-head .col-check {
    text-align: center;
}

.alarm-modal-table-head .col-check input {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.alarm-modal-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.alarm-modal-row {
    display: grid;
    grid-template-columns: 30px 40px 140px 120px 1fr 140px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    transition: background 0.15s;
    align-items: center;
    cursor: pointer;
}

.alarm-modal-row > div {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.alarm-modal-row:hover {
    background: var(--item-hover-bg);
}

.alarm-modal-row.aa-selected {
    background: rgba(24, 144, 255, 0.12);
}

.alarm-modal-row .col-check {
    text-align: center;
}

.alarm-modal-row .col-check input {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.alarm-modal-row .col-status {
    text-align: center;
}

.alarm-modal-row .col-device {
    font-family: monospace;
    font-weight: 500;
}

.alarm-modal-row .col-code {
    font-family: monospace;
    font-size: 11px;
}

.alarm-modal-row .col-time {
    font-family: monospace;
    font-size: 11px;
    color: var(--text-secondary);
}

/* 亮色主题 */
.theme-light .alarm-modal-table-head {
    background: #f5f7fa;
}

.theme-light .alarm-modal-row.aa-selected {
    background: rgba(24, 144, 255, 0.08);
}
