/* ============================================
   STM32 WebUSB DFU 刷机工具 - 样式表
   作者: LCKFB-YZH
   ============================================ */

:root {
    --sidebar-width: 260px;
    --log-panel-height: 200px;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #3b82f6;
    --sidebar-hover: #334155;
    --main-bg: #f1f5f9;
    --card-bg: #ffffff;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --info: #06b6d4;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08);
    --radius: 8px;
    --radius-lg: 12px;
    --font-mono: 'Consolas', 'Monaco', 'Courier New', monospace;
    --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: system-ui, -apple-system, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: var(--main-bg);
    color: var(--text-primary);
    height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ============ 布局 ============ */
.app-layout { display: flex; flex: 1; min-height: 0; overflow: hidden; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    z-index: 10;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
}
.sidebar-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    gap: 14px;
}

.logo-link {
    display: block;
    width: 100%;
    text-align: center;
    transition: opacity var(--transition);
}

.logo-link:hover { opacity: 0.85; }

.logo-img {
    width: 100%;
    max-width: 176px;
    height: auto;
    filter: brightness(1.1);
    display: block;
    margin: 0 auto;
}

.app-title-group {
    text-align: center;
    width: 100%;
}

.app-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #f1f5f9;
    line-height: 1.3;
    letter-spacing: 0.02em;
}

.app-subtitle {
    font-size: 0.75rem;
    color: rgba(148,163,184,0.65);
    margin-top: 4px;
    letter-spacing: 0.03em;
}

.sidebar-connection {
    padding: 16px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.btn-connect {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius);
    background: transparent;
    color: #e2e8f0;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-connect:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.25); }
.btn-connect:active { transform: scale(0.98); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.disconnected { background: #ef4444; }
.status-dot.connected { background: #10b981; box-shadow: 0 0 6px rgba(16,185,129,0.5); }

.device-brief {
    margin-top: 10px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.device-chip { color: #e2e8f0; font-weight: 600; }
.device-vid-pid { color: var(--sidebar-text); font-family: var(--font-mono); font-size: 0.75rem; }

.chip-select {
    margin-top: 10px;
}

.chip-select select {
    width: 100%;
    padding: 7px 8px;
    font-size: 0.8rem;
    background: rgba(255,255,255,0.08);
    color: #e2e8f0;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 6px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}

.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: var(--sidebar-active); color: #ffffff; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-icon { opacity: 0.7; flex-shrink: 0; }

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.7rem;
    color: rgba(148,163,184,0.6);
    text-align: center;
}

.sidebar-footer p { line-height: 1.6; }

/* ============ 页面通用 ============ */
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h2 { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); }
.page-body { display: flex; flex-direction: column; gap: 20px; }
.hidden { display: none !important; }

/* ============ 按钮 ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--border); color: var(--text-primary); }
.btn-secondary:hover:not(:disabled) { background: #cbd5e1; }
.btn-info { background: var(--info); color: white; }
.btn-info:hover:not(:disabled) { background: #0891b2; }
.btn-warning { background: var(--warning); color: #1e293b; }
.btn-warning:hover:not(:disabled) { background: #d97706; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--border-light); }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; width: 100%; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: background var(--transition);
}

.btn-icon:hover { background: rgba(255,255,255,0.1); }

/* ============ 表单 ============ */
.form-row { display: flex; gap: 16px; align-items: flex-end; }
.form-group { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.form-group-btn { flex: 0 0 auto; }

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

input[type="text"],
input[type="number"],
select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--card-bg);
    color: var(--text-primary);
    transition: border-color var(--transition);
    outline: none;
}

input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.input-mono { font-family: var(--font-mono); }
.checkbox-group { flex: 0 0 auto; justify-content: flex-end; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding-bottom: 9px;
}

.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }

/* ============ 拖放区 ============ */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--card-bg);
}

.drop-zone:hover { border-color: var(--primary); background: #f8faff; }
.drop-zone.drag-over { border-color: var(--primary); background: #eff6ff; transform: scale(1.005); }
.drop-zone.has-file { border-style: solid; border-color: var(--success); background: #f0fdf4; }
.file-input-hidden { display: none; }
.drop-zone-content { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.drop-icon { color: var(--text-muted); }
.drop-text { font-size: 0.95rem; color: var(--text-primary); font-weight: 500; }
.drop-hint { font-size: 0.8rem; color: var(--text-muted); }

/* ============ 文件信息 ============ */
.file-info {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.info-item { display: flex; flex-direction: column; gap: 2px; }
.info-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; font-weight: 600; letter-spacing: 0.03em; }
.info-value { font-size: 0.9rem; color: var(--text-primary); font-weight: 500; font-family: var(--font-mono); }

/* ============ 进度条 ============ */
.progress-container {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.progress-bar {
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), #60a5fa);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ============ Hex Viewer (表格式，类似 CubeProgrammer) ============ */
.mem-toolbar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.mem-toolbar .form-group { flex: 0 0 auto; min-width: 100px; }
.mem-toolbar .form-group:nth-child(4) { flex: 1; min-width: 120px; }

.hex-table-wrapper {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: auto;
    max-height: 520px;
    min-height: 200px;
}

.hex-placeholder { color: var(--text-muted); text-align: center; padding: 60px 0; }

.hex-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
}

.hex-table thead { position: sticky; top: 0; z-index: 1; }

.hex-table th {
    background: #1e293b;
    color: #94a3b8;
    padding: 6px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
    border-bottom: 2px solid #334155;
    white-space: nowrap;
}

.hex-table th:first-child { text-align: left; padding-left: 12px; }
.hex-table th:last-child { text-align: left; padding-left: 12px; }

.hex-table td {
    padding: 4px 8px;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

.hex-table tr:hover td { background: #f0f7ff; }

.hex-table td:first-child {
    text-align: left;
    padding-left: 12px;
    color: #64748b;
    font-weight: 600;
    background: #f8fafc;
    border-right: 1px solid var(--border);
    user-select: none;
}

.hex-table td:last-child {
    text-align: left;
    padding-left: 12px;
    color: #64748b;
    border-left: 1px solid var(--border);
    letter-spacing: 0.5px;
}

.hex-table .byte-zero { color: #cbd5e1; }
.hex-table .byte-ff { color: #94a3b8; }
.hex-table .byte-highlight { background: #fef3c7; color: #92400e; }

/* ============ 擦除页 ============ */
.erase-mass {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.erase-mass-info h3 { font-size: 1rem; margin-bottom: 4px; }
.erase-mass-info p { font-size: 0.85rem; color: var(--text-secondary); }
.erase-sector-section { margin-top: 8px; }

.erase-sector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.erase-sector-header h3 { font-size: 1rem; }
.sector-actions { display: flex; gap: 8px; }

.sector-map {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.sector-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}

.sector-card:hover { border-color: #cbd5e1; }
.sector-card.selected { border-color: var(--warning); background: #fffbeb; }
.sector-checkbox { width: 16px; height: 16px; accent-color: var(--warning); pointer-events: none; }
.sector-info { flex: 1; }
.sector-name { font-weight: 600; font-size: 0.9rem; }
.sector-addr { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-secondary); }
.sector-size { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; white-space: nowrap; }

/* ============ 选项字节页 (折叠面板) ============ */
.page-header-actions { display: flex; gap: 8px; }

.ob-summary {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 20px;
}

.ob-summary-item { display: flex; align-items: center; gap: 8px; }
.ob-summary-label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.ob-raw-code { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-secondary); background: #f1f5f9; padding: 2px 8px; border-radius: 4px; }

.ob-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.ob-section[open] { border-color: var(--primary); }

.ob-section-title {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border-bottom: 1px solid transparent;
}

.ob-section[open] .ob-section-title { border-bottom-color: var(--border); background: #eff6ff; }

.ob-section-title::before {
    content: '▶';
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.ob-section[open] .ob-section-title::before { transform: rotate(90deg); }
.ob-section-title::-webkit-details-marker { display: none; }

.ob-section-body { padding: 16px; }

.ob-field { margin-bottom: 12px; }
.ob-field label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.ob-field select { width: 100%; max-width: 450px; }

.ob-hint { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }

.ob-help-compact { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.ob-help-compact p { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.6; display: flex; align-items: baseline; gap: 8px; }

.tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.tag-green { background: #dcfce7; color: #166534; }
.tag-yellow { background: #fef3c7; color: #92400e; }
.tag-red { background: #fee2e2; color: #991b1b; }

.ob-checkbox-list { display: flex; flex-direction: column; gap: 12px; }

.ob-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background var(--transition);
}

.ob-checkbox:hover { background: #f8fafc; }
.ob-checkbox input[type="checkbox"] { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--primary); flex-shrink: 0; }
.ob-checkbox-name { display: block; font-size: 0.9rem; font-weight: 500; }
.ob-checkbox-hint { display: block; font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.wrp-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.wrp-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    font-size: 0.85rem;
    gap: 4px;
}

.wrp-sector { font-weight: 600; }

.wrp-unprotected {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.wrp-unprotected .wrp-status { color: #166534; font-weight: 500; }

.wrp-protected {
    border-color: #fecaca;
    background: #fef2f2;
}

.wrp-protected .wrp-status { color: #991b1b; font-weight: 500; }

.option-setting-row {
    margin-bottom: 12px;
}

.option-setting-row label:not(.checkbox-label) {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.option-setting-row select {
    width: 100%;
    max-width: 400px;
}

.option-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
    margin-left: 24px;
    line-height: 1.5;
}

.wrp-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    width: 100%;
}

.wrp-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}
.option-bytes-raw { margin-top: 20px; }
.option-bytes-raw h3 { font-size: 1rem; margin-bottom: 12px; }

.option-hex {
    background: #0f172a;
    color: #e2e8f0;
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 12px 16px;
    border-radius: var(--radius);
    word-break: break-all;
}

.danger-zone {
    margin-top: 24px;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 20px;
    background: #fef2f2;
}

.danger-zone h3 { color: var(--danger); font-size: 1rem; margin-bottom: 12px; }

.danger-warning {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    color: #991b1b;
    font-size: 0.85rem;
    line-height: 1.6;
}

.danger-warning svg { flex-shrink: 0; margin-top: 2px; color: var(--danger); }

/* ============ 设备信息页 ============ */
.device-info-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.no-device-hint { color: var(--text-muted); text-align: center; padding: 20px 0; }

.device-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.device-info-item { display: flex; flex-direction: column; gap: 4px; }
.device-info-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; font-weight: 600; }
.device-info-value { font-size: 0.95rem; font-weight: 500; font-family: var(--font-mono); }

.flash-map { display: flex; gap: 4px; margin-bottom: 24px; height: 48px; }

.flash-sector-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    cursor: default;
    transition: opacity var(--transition);
    overflow: hidden;
    padding: 2px;
}

.flash-sector-bar:hover { opacity: 0.85; }
.flash-sector-bar span { line-height: 1.2; }

.changelog { display: flex; flex-direction: column; gap: 16px; }

.changelog-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.changelog-version {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-right: 8px;
}

.changelog-date { font-size: 0.8rem; color: var(--text-muted); }
.changelog-item p { margin-top: 8px; font-size: 0.9rem; color: var(--text-secondary); line-height: 1.6; }

/* ============ 日志面板 ============ */
.log-panel {
    border-top: 1px solid var(--border);
    background: var(--card-bg);
    flex-shrink: 0;
}

.log-panel.collapsed .log-output { display: none; }

.log-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 16px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border);
}

.log-panel-title { font-weight: 600; font-size: 0.85rem; color: var(--text-secondary); }
.log-controls { display: flex; align-items: center; gap: 6px; }

.log-filter-select {
    padding: 3px 8px;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--text-secondary);
}

.log-output {
    height: var(--log-panel-height);
    overflow-y: auto;
    padding: 8px 16px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.6;
    background: #0f172a;
}

.log-entry { padding: 1px 0; }
.log-entry.info { color: #94a3b8; }
.log-entry.success { color: #34d399; }
.log-entry.warning { color: #fbbf24; }
.log-entry.error { color: #f87171; }
.log-entry.link { color: #38bdf8; font-weight: 600; }
.log-entry.link a {
    color: #38bdf8;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.log-entry.link a:hover { color: #7dd3fc; }

/* ============ Modal ============ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    backdrop-filter: blur(2px);
}

.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    transform: scale(0.95);
    transition: transform 0.2s;
}

.modal-overlay.active .modal { transform: scale(1); }
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; }
.modal-message { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.6; margin-bottom: 24px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ============ Toast ============ */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    color: white;
    font-weight: 500;
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toastIn 0.3s ease-out;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: #1e293b; }
.toast.info { background: var(--info); }

@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* ============ 备案页脚 ============ */
.site-footer {
    background: var(--sidebar-bg);
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: 10px 20px;
    flex-shrink: 0;
}

.site-footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px 4px;
    font-size: 0.72rem;
    color: rgba(148,163,184,0.6);
}

.site-footer-inner a {
    color: rgba(148,163,184,0.7);
    text-decoration: none;
    transition: color var(--transition);
}

.site-footer-inner a:hover { color: #94a3b8; }

.footer-sep {
    color: rgba(148,163,184,0.3);
    user-select: none;
}
@media (max-width: 768px) {
    .app-layout { flex-direction: column; }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    .sidebar-header { padding: 10px 16px; border-bottom: none; }
    .sidebar-header .app-subtitle { display: none; }

    .sidebar-connection {
        padding: 8px 12px;
        border-bottom: none;
        border-left: 1px solid rgba(255,255,255,0.08);
        margin-left: auto;
    }

    .device-brief { display: none; }

    .sidebar-nav {
        flex-direction: row;
        width: 100%;
        overflow-x: auto;
        padding: 4px 8px;
        border-top: 1px solid rgba(255,255,255,0.08);
        gap: 2px;
    }

    .nav-item { padding: 8px 12px; flex-shrink: 0; }
    .nav-text { display: none; }
    .sidebar-footer { display: none; }
    .content-wrapper { padding: 16px; }
    .form-row { flex-direction: column; }
    .sector-map { grid-template-columns: 1fr; }
}
