:root {
    --primary: #1f8abe;
    --primary-dark: #1870a0;
    --primary-light: #40a8d8;
    --bg: #f5f7fc;
    --card-bg: #ffffff;
    --text: #1e2a3e;
    --text-secondary: #6b7f8a;
    --border: #e8edf2;
    --danger: #e74c3c;
    --warning: #f39c12;
    --success: #27ae60;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
    --sidebar-width: 260px;
    --nav-height: 56px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    height: 100vh;
}

/* Login Overlay (reused from OTA) */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5f7fc 0%, #e8edf2 100%);
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    width: 380px;
    max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0,0,0,0.10);
    border: 1px solid var(--border);
    text-align: center;
}

.login-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    background: linear-gradient(145deg, var(--primary), var(--primary-light));
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    box-shadow: 0 8px 20px rgba(31,138,190,0.25);
}

.login-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.login-card .form-group {
    margin-bottom: 16px;
    position: relative;
}

.login-card .form-group label {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.login-card .form-group input {
    width: 100%;
    padding: 12px 14px 12px 40px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    background: #fafbfc;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.login-card .form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31,138,190,0.10);
    background: white;
}

.login-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-bottom: 12px;
    text-align: left;
    min-height: 20px;
}

.login-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(31,138,190,0.25);
}

.login-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(31,138,190,0.30);
}

.login-btn i {
    transition: transform 0.2s;
}

.login-btn:hover i {
    transform: translateX(3px);
}

.login-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.login-back:hover {
    color: var(--primary);
}

/* Nav */
.flasher-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    z-index: 100;
    background: rgba(255,255,255,0.90);
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border);
}

.flasher-nav-inner {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.flasher-nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
    margin-right: auto;
}

.flasher-nav-brand i {
    font-size: 1.2rem;
}

.flasher-nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.83rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.nav-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(31,138,190,0.05);
}

.nav-btn.admin-btn:hover {
    border-color: var(--warning);
    color: var(--warning);
    background: rgba(243,156,18,0.06);
}

.nav-btn.nav-btn-danger {
    border-color: rgba(231,76,60,0.2);
    color: var(--danger);
}

.nav-btn.nav-btn-danger:hover {
    border-color: rgba(231,76,60,0.3);
    color: var(--danger);
    background: rgba(231,76,60,0.06);
}

/* Main Layout */
.main-content {
    padding-top: var(--nav-height);
    height: 100vh;
}

.dashboard {
    display: flex;
    height: calc(100vh - var(--nav-height));
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.sidebar-backdrop {
    display: none;
}

.mobile-sidebar-edge-toggle {
    display: none;
}

.sidebar-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-header h3 i {
    margin-right: 6px;
}

.sidebar-add-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.sidebar-add-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(31,138,190,0.05);
}

.project-list {
    padding: 8px;
}

.project-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 2px;
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text);
    border: 1px solid transparent;
}

.project-item:hover {
    background: rgba(31,138,190,0.05);
}

.project-item.active {
    background: rgba(31,138,190,0.08);
    border-color: rgba(31,138,190,0.18);
    color: var(--primary);
    font-weight: 600;
}

.project-item i {
    font-size: 1rem;
    color: var(--primary);
    width: 20px;
    text-align: center;
}

.project-item.custom-project {
    margin-bottom: 8px;
    border-color: rgba(31,138,190,0.14);
    background: linear-gradient(180deg, rgba(31,138,190,0.04), rgba(31,138,190,0.01));
}

.project-item.custom-project .custom-project-note {
    font-size: 0.72rem;
    color: #999;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Content Area */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.no-project {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60%;
    color: var(--text-secondary);
}

.no-project i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.no-project p {
    font-size: 1rem;
}

/* Project Detail */
.project-detail {
    width: 100%;
}

.project-detail-columns {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 20px;
}

.project-detail-layout {
    display: flex;
    flex-direction: column;
    flex: 0 0 800px;
    gap: 20px;
    width: 800px;
}

.project-detail-main {
    width: 100%;
}

.project-detail-side {
    flex: 0 0 800px;
    width: 800px;
}

.project-detail-side .flash-log-wrap .flash-log {
    height: 300px;
    min-height: 120px;
    max-height: 60vh;
}

.detail-header {
    margin-bottom: 20px;
}

.detail-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.detail-title h2 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Project Intro Card */
.project-intro {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.project-intro h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 10px;
}

.project-intro h3 i {
    margin-right: 6px;
    color: var(--primary);
}

.project-intro p {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 12px;
}

.browser-warning {
    background: rgba(243,156,18,0.10);
    border: 1px solid rgba(243,156,18,0.25);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 16px;
    font-size: 0.87rem;
    color: var(--warning);
    align-items: center;
    gap: 8px;
}

.learn-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--primary);
    text-decoration: none;
}

.learn-more-btn:hover {
    border-color: var(--primary);
    background: rgba(31,138,190,0.05);
}

.intro-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.intro-text {
    flex: 1;
    min-width: 0;
}

.intro-image {
    flex-shrink: 0;
    width: 180px;
    height: 180px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    background: #fafbfc;
    position: relative;
}

.intro-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-loading-hint {
    display: none;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-size: 0.85rem;
}

.intro-image.loading .image-loading-hint {
    display: flex;
}

.intro-image.loading img {
    display: none;
}

/* Port Selector */
.local-file-row {
    display: flex;
}

.custom-file-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.custom-file-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    background: #fafbfc;
}

.custom-file-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.port-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #fafbfc;
    outline: none;
    transition: border-color 0.2s;
    color: var(--text);
}

.port-input:focus {
    border-color: var(--primary);
    background: white;
}

.port-input-clickable {
    cursor: pointer;
    color: var(--text-secondary);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s, color 0.2s;
}

.port-input-clickable:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(31,138,190,0.06);
}

.port-input-clickable:focus {
    color: var(--text);
}

.port-list {
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.port-list-item {
    padding: 8px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.port-list-item:last-child {
    border-bottom: none;
}

.port-list-item:hover {
    background: rgba(31,138,190,0.05);
}

.port-list-item i {
    color: var(--primary);
    font-size: 0.85rem;
}

/* 端口选择模态框 — 居中弹窗 */
.port-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(4px);
}

.port-modal-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    width: 400px;
    max-width: 90vw;
    max-height: 70vh;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.port-modal-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.port-modal-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.port-modal-header h3 i {
    color: var(--primary);
}

.port-modal-close {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.port-modal-close:hover {
    background: rgba(0,0,0,0.05);
}

.port-modal-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    min-height: 60px;
}

.port-modal-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

.port-modal-item:last-child {
    border-bottom: none;
}

.port-modal-item:hover {
    background: rgba(31,138,190,0.06);
}

.port-modal-item i {
    color: var(--primary);
    font-size: 1rem;
}

.port-modal-item .port-name {
    font-size: 0.88rem;
    font-weight: 600;
}

.port-modal-empty {
    padding: 24px 20px 8px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.port-modal-hint {
    padding: 0 20px 24px;
    text-align: center;
    color: #e6a23c;
    font-size: 0.75rem;
    line-height: 1.4;
}

.port-modal-footer {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

.port-modal-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid var(--border);
}

.port-modal-btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.port-modal-btn-primary:hover {
    background: var(--primary-dark);
}

.port-modal-btn-cancel {
    background: transparent;
    color: var(--text-secondary);
}

.port-modal-btn-cancel:hover {
    background: rgba(0,0,0,0.04);
}

/* Flash Card */
.flash-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.flash-card h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 16px;
}

.flash-card h3 i {
    margin-right: 6px;
    color: var(--primary);
}

.flash-card .form-group {
    margin-bottom: 16px;
}

.flash-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.flash-card-header h3 {
    margin-bottom: 0;
}

.flash-card-header .flash-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.flash-card-header .flash-btn {
    min-width: 120px;
    padding: 8px 16px;
    border-radius: 9px;
    font-size: 0.88rem;
}

/* 卡片化表单控件（可复用于 flasher/activate 页面） */
.form-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    background: #fafbfc;
}
.form-card .form-card-label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}
.form-card .form-card-control,
.form-card select,
.form-card input[type="text"],
.form-card textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #fff;
    outline: none;
    box-sizing: border-box;
    color: var(--text);
}
.form-card select:focus,
.form-card input:focus,
.form-card textarea:focus {
    border-color: var(--primary);
}
.form-card .form-card-control.port-input-clickable,
.form-card input.port-input-clickable {
    cursor: pointer;
}

.flash-inline-config {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 0.5fr);
    gap: 12px;
    align-items: end;
    margin-bottom: 16px;
}

.flash-inline-config .form-card,
.flash-inline-config .flash-actions {
    margin-bottom: 0;
}

.flash-inline-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
    margin-top: 0;
}

.flash-inline-actions .flash-btn {
    width: 100%;
    white-space: nowrap;
}

.flash-inline-actions.is-running {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: stretch;
}

.flash-inline-actions.is-running #flash-start-btn {
    width: 100%;
    min-width: 0;
    padding-left: 16px;
    padding-right: 16px;
}

.flash-inline-actions #flash-cancel-btn {
    width: 100%;
    min-width: 0;
    padding: 0;
    border-radius: 10px;
}

.flash-inline-actions.is-running #flash-cancel-btn {
    background: #e74c3c;
    border: none;
    color: #fff;
    box-shadow: 0 4px 14px rgba(231,76,60,0.28);
}

.flash-inline-actions.is-running #flash-cancel-btn:hover {
    background: #cf3f31;
    border: none;
    color: #fff;
}

.flash-card .form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.flash-card .form-group select,
.flash-card .form-group input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #fafbfc;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    appearance: auto;
}

.flash-card .form-group select:focus,
.flash-card .form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31,138,190,0.10);
    background: white;
}

.flash-card .form-group select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.offset-input-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.offset-prefix {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    min-width: auto;
    font-size: 0.88rem;
    font-family: monospace;
    color: var(--text-secondary);
    font-weight: 600;
    line-height: 1;
    transition: color 0.2s;
}

.offset-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: monospace;
    outline: none;
    background: #fafbfc;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.offset-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31,138,190,0.10);
    background: white;
}

.offset-input-group.has-value .offset-prefix {
    color: var(--text);
}

.offset-input-group.offset-input-group-sm .offset-prefix {
    font-size: 0.85rem;
}

.flash-mode-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.flash-mode-option {
    flex: 1;
    min-width: 180px;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    background: #fafbfc;
    text-align: center;
}

.flash-mode-option:hover {
    border-color: rgba(31,138,190,0.3);
}

.flash-mode-option.selected {
    border-color: var(--primary);
    background: rgba(31,138,190,0.06);
}

.flash-mode-option .mode-icon {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 6px;
}

.flash-mode-option .mode-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.flash-mode-option .mode-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* Flash Buttons */
.flash-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.flash-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.flash-btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 14px rgba(31,138,190,0.30);
}

.flash-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(31,138,190,0.35);
}

.flash-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.flash-btn-danger {
    background: transparent;
    border: 1px solid rgba(231,76,60,0.25);
    color: var(--danger);
}

.flash-btn-danger:hover {
    background: rgba(231,76,60,0.06);
    border-color: rgba(231,76,60,0.35);
}

/* Flash Version Info */
.version-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.version-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.version-tag.fw {
    background: rgba(31,138,190,0.10);
    color: var(--primary);
}

.version-tag.hw {
    background: rgba(230,126,34,0.10);
    color: #9b59b6;
}

.version-tag.bl {
    background: rgba(243,156,18,0.10);
    color: var(--warning);
}

.version-tag.fs {
    background: rgba(155,89,182,0.10);
    color: #e67e22;
}

.version-tag.pt {
    background: rgba(39,174,96,0.10);
    color: var(--success);
}

/* Progress Area */
.flash-progress-area {
    display: none;
    margin-top: 16px;
}

.flash-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.87rem;
}

.flash-progress-header .status-text {
    font-weight: 600;
}

.flash-progress-header .progress-pct {
    font-weight: 600;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

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

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

.flash-progress-fill.active {
    background: linear-gradient(90deg, var(--primary), var(--primary-light), #5bc0eb, var(--primary-light), var(--primary));
    background-size: 400% 100%;
    animation: progressPulse 1.8s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.flash-log-wrap {
    position: relative;
}

.flash-log {
    height: 200px;
    overflow-y: auto;
    background: #0a1628;
    border-radius: 8px 8px 0 0;
    padding: 12px 14px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.78rem;
    line-height: 1.6;
    color: #a8d8ea;
    min-height: 80px;
    max-height: 80vh;
}

.flash-log-resize-bar {
    height: 10px;
    background: #1a2a3a;
    border-radius: 0 0 8px 8px;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    user-select: none;
    border-top: 1px solid rgba(85,170,153,0.25);
}

.flash-log-resize-bar:hover {
    background: #1e3044;
}

.flash-log-resize-bar .grip-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #5a9;
    opacity: 0.5;
}

.flash-log-resize-bar:hover .grip-dot {
    opacity: 0.9;
}

.flash-log .log-info {
    color: #81d4fa;
}

.flash-log .log-ok {
    color: #66bb6a;
}

.flash-log .log-err {
    color: #ef5350;
}

.flash-log .log-warn {
    color: #ffa726;
}

/* Buttons (OTA style) */
.btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 7px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(31,138,190,0.04);
}

.btn-danger {
    background: transparent;
    border: 1px solid rgba(231,76,60,0.20);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(231,76,60,0.06);
    border-color: rgba(231,76,60,0.30);
}

.btn-success {
    background: transparent;
    border: 1px solid rgba(39,174,96,0.20);
    color: var(--success);
}

.btn-success:hover {
    background: rgba(39,174,96,0.06);
    border-color: rgba(39,174,96,0.30);
}

.ver-version-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
}

.ver-flash-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(31,138,190,0.08);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
}

.ver-public-switch {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.ver-public-switch input {
    margin: 0;
}

/* Toast */
.toast {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 2000;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background: var(--success);
    box-shadow: 0 4px 16px rgba(39,174,96,0.30);
}

.toast.error {
    background: var(--danger);
    box-shadow: 0 4px 16px rgba(231,76,60,0.30);
}

/* Loading */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d0d8e0;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #b0b8c0;
}

@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    .dashboard {
        position: relative;
    }

    .flasher-nav-inner {
        padding: 0 12px;
        gap: 8px;
    }

    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(280px, 78vw);
        z-index: 30;
        transform: translateX(calc(-100% - 12px));
        box-shadow: none;
    }

    .mobile-sidebar-edge-toggle {
        position: absolute;
        top: 50%;
        left: -3px;
        z-index: 40;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 24px;
        height: 44px;
        padding: 0;
        border: none;
        background: transparent;
        color: rgba(30,42,62,0.55);
        font-size: 1rem;
        cursor: pointer;
        transform: translateY(-50%);
        transition: left 0.25s ease, color 0.2s ease, transform 0.2s ease;
        text-shadow: 0 1px 6px rgba(255,255,255,0.9);
    }

    .mobile-sidebar-edge-toggle::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: radial-gradient(circle, rgba(246,180,40,0.8) 0%, rgba(246,180,40,0.38) 45%, rgba(246,180,40,0) 75%);
        box-shadow: 0 0 18px rgba(246,180,40,0.5);
        transform: translate(-50%, -50%) scale(0.6);
        opacity: 0;
        pointer-events: none;
    }

    body.mobile-sidebar-hint-active .mobile-sidebar-edge-toggle::before {
        animation: mobile-sidebar-halo 1.8s ease-out infinite;
    }

    body.mobile-sidebar-hint-active .mobile-sidebar-edge-toggle {
        animation: mobile-sidebar-arrow-pulse 1.8s ease-in-out infinite;
    }

    .mobile-sidebar-edge-toggle:hover {
        color: var(--primary);
    }

    body.mobile-sidebar-open .mobile-sidebar-edge-toggle {
        left: calc(min(280px, 78vw) - 3px);
        color: var(--primary);
    }

    body.mobile-sidebar-open .mobile-sidebar-edge-toggle i {
        transform: rotate(180deg);
    }

    @keyframes mobile-sidebar-halo {
        0% {
            opacity: 0.9;
            transform: translate(-50%, -50%) scale(0.7);
        }
        70% {
            opacity: 0;
            transform: translate(-50%, -50%) scale(2);
        }
        100% {
            opacity: 0;
            transform: translate(-50%, -50%) scale(2);
        }
    }

    @keyframes mobile-sidebar-arrow-pulse {
        0% {
            opacity: 0.55;
            text-shadow: 0 1px 6px rgba(255,255,255,0.55);
        }
        50% {
            opacity: 1;
            text-shadow: 0 1px 10px rgba(255,255,255,0.95);
        }
        100% {
            opacity: 0.55;
            text-shadow: 0 1px 6px rgba(255,255,255,0.55);
        }
    }

    body.mobile-sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 0 12px 32px rgba(0,0,0,0.18);
    }

    .sidebar-backdrop {
        display: block;
        position: absolute;
        inset: 0;
        background: rgba(10,22,40,0.28);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
        z-index: 20;
    }

    body.mobile-sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .content-area {
        width: 100%;
        padding: 16px;
    }

    .intro-layout {
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 16px;
    }

    .intro-image {
        width: 100%;
        max-width: 260px;
        height: auto;
        aspect-ratio: 1 / 1;
        margin: 0 auto;
    }

    .intro-text {
        width: 100%;
    }

    .custom-file-grid {
        grid-template-columns: 1fr;
    }

    .flash-mode-group {
        flex-direction: column;
    }

    .flash-mode-option {
        min-width: auto;
    }

    .project-detail-side .flash-log-wrap .flash-log {
        height: 250px;
        max-height: 50vh;
    }
    .flash-inline-config {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .flash-inline-actions {
        justify-content: stretch;
        flex-wrap: wrap;
        margin-top: 4px;
    }
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    width: 420px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 12px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
}

.modal-body .form-group label {
    display: block;
    position: static;
    transform: none;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.modal-body .form-group input,
.modal-body .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    background: #fafbfc;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.modal-body .form-group input:focus,
.modal-body .form-group textarea:focus {
    border-color: var(--primary);
    background: white;
}

.modal-body .form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px 18px;
}
