/* =========================================================================
   ML SEU Exercise Helper — extracted styles
   Originally inlined as five <style> blocks inside templates/index.html.
   ========================================================================= */

/* ---------- 基础页面布局 ---------- */
body {
    background-color: #f8f9fa;
    color: #333;
}

.container {
    max-width: 800px;
}

.form-group {
    margin-bottom: 15px;
}

.btn-primary {
    margin-top: 20px;
    background-color: #007bff;
    border-color: #007bff;
}

.btn-primary:hover {
    background-color: #0056b3;
    border-color: #004085;
}

/* ---------- 按钮并排样式 ---------- */
.button-container {
    text-align: center; /* 可选：居中按钮 */
}

.button-inline {
    display: inline-block;
    margin: 5px; /* 可选：添加按钮之间的间距 */
}

/* ---------- 预览图片样式 ---------- */
/* 确保图片不会溢出预览区域 */
.preview-image img {
    max-width: 100%;
    height: auto;
    display: block; /* 移除图片底部可能存在的额外空间 */
}

/* ---------- 警告对话框样式 ---------- */
/* 遮罩层样式 */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* 更深的半透明黑色 */
    z-index: 1000;
    opacity: 0; /* 初始隐藏，用于动画 */
    visibility: hidden; /* 初始隐藏，防止点击 */
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.overlay.show {
    opacity: 1;
    visibility: visible;
}

/* 自定义警告对话框样式 */
.custom-alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9); /* 初始略微缩小，用于动画 */
    width: 90%; /* 响应式宽度 */
    max-width: 400px; /* 最大宽度 */
    background-color: white;
    border-radius: 10px; /* 圆角 */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); /* 更明显的阴影 */
    z-index: 1010;
    overflow: hidden; /* 确保子元素圆角生效 */
    opacity: 0; /* 初始隐藏，用于动画 */
    visibility: hidden; /* 初始隐藏，防止点击 */
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
}

#ml-detail-overlay {
    z-index: 1290;
}

#overlay {
    z-index: 2000;
}

#ml-confirm-overlay {
    z-index: 2010;
}

#ml_Alert_region {
    z-index: 2020;
}

#ml_confirm_region {
    z-index: 2030;
}

.custom-alert.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1); /* 动画到正常大小 */
}

/* 对话框头部样式 */
.custom-alert-header {
    display: flex; /* 弹性布局 */
    justify-content: space-between; /* 标题和关闭按钮两端对齐 */
    align-items: center; /* 垂直居中 */
    padding: 15px 20px;
    background-color: #f8f9fa; /* 浅灰色背景 */
    border-bottom: 1px solid #e9ecef; /* 分隔线 */
}

.custom-alert-title {
    font-size: 1.25em; /* 标题字体大小 */
    font-weight: 600; /* 更粗的字体 */
    color: #343a40; /* 深灰色文本 */
    margin: 0; /* 移除默认外边距 */
}

/* 关闭按钮样式 */
.custom-alert-close {
    background: none;
    border: none;
    font-size: 1.5em;
    color: #6c757d; /* 灰色 */
    cursor: pointer;
    padding: 0; /* 移除默认内边距 */
    line-height: 1; /* 确保X字符居中 */
    transition: color 0.2s ease;
}

.custom-alert-close:hover {
    color: #343a40; /* 鼠标悬停时更深的颜色 */
}

/* 对话框内容区域样式 */
.custom-alert-content {
    padding: 20px;
    color: #495057; /* 稍深的文本颜色 */
    line-height: 1.6; /* 增加行高，提高可读性 */
    font-size: 1em;
}

.custom-alert-message {
    margin-bottom: 0; /* 移除默认外边距 */
}

/* 对话框脚部样式 */
.custom-alert-footer {
    padding: 10px 16px;
    border-top: 1px solid #e9ecef; /* 分隔线 */
    background-color: #f8f9fa; /* 浅灰色背景 */
    text-align: right; /* 按钮右对齐 */
}

/* 确定按钮样式 */
.custom-alert-button {
    padding: 6px 18px;
    background-color: #007bff; /* 主色调蓝色 */
    color: white;
    border: none;
    border-radius: 5px; /* 圆角 */
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.2);
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.custom-alert-button:hover {
    background-color: #0056b3; /* 鼠标悬停时更深的蓝色 */
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3);
}

/* ---------- 锻炼数据卡片样式 ---------- */
.ml-exercise-summary-card {
    position: fixed;
    top: 12px;
    left: 12px;
    width: 300px;
    max-width: calc(100vw - 24px);
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);
    z-index: 1200;
    overflow: hidden;
}

.ml-exercise-summary-card .ml-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #f1f3f5;
    background-color: #f8f9fa;
}

.ml-exercise-summary-card .ml-card-total {
    font-size: 0.92rem;
    color: #495057;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ml-exercise-summary-card .ml-card-total .ml-total-number {
    color: #0d6efd;
    font-weight: 600;
}

.ml-exercise-summary-card .ml-card-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.ml-exercise-summary-card .ml-card-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid #d6d8db;
    background: #fff;
    color: #495057;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 0.82rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ml-exercise-summary-card .ml-card-btn:hover:not(:disabled) {
    background-color: #eef5ff;
    border-color: #bfd7ff;
    color: #0d6efd;
}

.ml-exercise-summary-card .ml-card-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.ml-exercise-summary-card .ml-refresh-icon {
    color: #6c757d;
}

.ml-exercise-summary-card .ml-expand-btn {
    width: 28px;
    justify-content: center;
    padding: 4px 0;
    color: #6c757d;
}

.ml-exercise-summary-card .ml-expand-icon {
    color: #0d6efd;
    transition: transform 0.2s ease;
}

.ml-exercise-summary-card .ml-expand-icon.expanded {
    transform: rotate(180deg);
}

.ml-exercise-summary-card .ml-card-body {
    padding: 10px 12px;
    background-color: #ffffff;
}

.ml-exercise-summary-card .ml-card-hint {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #6c757d;
    font-size: 0.82rem;
    margin: 0;
}

.ml-exercise-summary-card .ml-card-hint-icon {
    color: #5a7db8;
    flex-shrink: 0;
}

.ml-exercise-summary-card .ml-card-hint-text {
    color: #6c757d;
}

.ml-exercise-summary-card .ml-card-records {
    display: none;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 8px;
    border-top: 1px dashed #dee2e6;
    padding-top: 8px;
}

.ml-exercise-summary-card .ml-record-item {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 8px;
    background-color: #fcfdff;
}

.ml-exercise-summary-card .ml-record-item:last-child {
    margin-bottom: 0;
}

.ml-exercise-summary-card .ml-record-item-running {
    border-color: #cfe2ff;
    background: linear-gradient(180deg, #f4f8ff 0%, #ffffff 100%);
}

.ml-exercise-summary-card .ml-record-item-free {
    border-color: #ddd6fe;
    background: linear-gradient(180deg, #f7f5ff 0%, #ffffff 100%);
}

.ml-exercise-summary-card .ml-record-item-unknown {
    border-color: #dee2e6;
    background: linear-gradient(180deg, #f3f4f6 0%, #ffffff 100%);
}

.ml-exercise-summary-card .ml-record-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #334155;
}

.ml-exercise-summary-card .ml-record-title-running {
    color: #0b5ed7;
}

.ml-exercise-summary-card .ml-record-title-free {
    color: #6f42c1;
}

.ml-exercise-summary-card .ml-record-title-unknown {
    color: #6c757d;
}

.ml-exercise-summary-card .ml-record-details {
    margin-left: 10px;
    padding-left: 8px;
    border-left: 2px solid #e9ecef;
}

.ml-exercise-summary-card .ml-record-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 0.75rem;
    line-height: 1.2;
    border: 1px solid #ced4da;
    background-color: #f1f3f5;
    color: #495057;
}

.ml-exercise-summary-card .ml-record-badge-valid {
    border-color: #b7ebc6;
    background-color: #eafaf0;
    color: #198754;
}

.ml-exercise-summary-card .ml-record-badge-invalid {
    border-color: #f5c2c7;
    background-color: #fff1f2;
    color: #dc3545;
}

.ml-exercise-summary-card .ml-record-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.79rem;
    color: #495057;
    margin-bottom: 3px;
}

.ml-exercise-summary-card .ml-record-row:last-child {
    margin-bottom: 0;
}

.ml-exercise-summary-card .ml-record-label {
    color: #6c757d;
    white-space: nowrap;
}

.ml-exercise-summary-card .ml-record-value {
    text-align: right;
    word-break: break-word;
}

.ml-exercise-summary-card .ml-record-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.ml-exercise-summary-card .ml-record-detail-btn {
    border: 1px solid #bfd7ff;
    background: #eef5ff;
    color: #0d6efd;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.78rem;
    line-height: 1.2;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ml-exercise-summary-card .ml-record-detail-btn:hover:not(:disabled) {
    background: #dceaff;
    border-color: #8fbcff;
}

.ml-exercise-summary-card .ml-record-detail-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* ---------- 锻炼记录详情弹窗 ---------- */
.ml-detail-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    width: min(720px, calc(100vw - 24px));
    max-height: calc(100vh - 32px);
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.18);
    z-index: 1300;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.ml-detail-modal.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.ml-detail-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #edf1f5;
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

.ml-detail-modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
}

.ml-detail-modal-title-text {
    display: inline-block;
}

.ml-detail-modal-title-badge {
    display: none;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 0.75rem;
    line-height: 1.2;
    border: 1px solid #ced4da;
    background-color: #f1f3f5;
    color: #495057;
    font-weight: 500;
}

.ml-detail-modal-title-badge.show {
    display: inline-block;
}

.ml-detail-modal-title-badge-valid {
    border-color: #b7ebc6;
    background-color: #eafaf0;
    color: #198754;
}

.ml-detail-modal-title-badge-invalid {
    border-color: #f5c2c7;
    background-color: #fff1f2;
    color: #dc3545;
}

.ml-detail-modal-close {
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.ml-detail-modal-body {
    padding: 16px 18px 18px;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
}

.ml-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.ml-detail-item {
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 10px 12px;
    background: #fbfdff;
}

.ml-detail-item-label {
    display: block;
    margin-bottom: 4px;
    color: #6b7280;
    font-size: 0.78rem;
}

.ml-detail-item-value {
    color: #1f2937;
    font-size: 0.92rem;
    word-break: break-word;
}

.ml-detail-section {
    margin-top: 14px;
}

.ml-detail-section-title {
    margin: 0 0 8px;
    color: #334155;
    font-size: 0.92rem;
    font-weight: 600;
}

.ml-detail-track-card {
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 10px;
    background: #fbfdff;
}

.ml-detail-track-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-bottom: 10px;
    color: #6b7280;
    font-size: 0.82rem;
}

.ml-detail-track-meta-break {
    flex-basis: 100%;
    height: 0;
}

.ml-detail-track-meta-line {
    flex-basis: 100%;
}

.ml-detail-track-canvas-wrap {
    border: 1px solid #dbe4ee;
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.ml-detail-track-canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
}

.ml-detail-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.ml-detail-image-card {
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 10px;
    background: #fbfdff;
}

.ml-detail-image-title {
    margin: 0 0 8px;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 600;
}

.ml-detail-image {
    width: 100%;
    max-height: 240px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #f8f9fa;
}

.ml-detail-empty {
    color: #6b7280;
    font-size: 0.85rem;
}

.ml-detail-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 12px;
}

.ml-detail-action-btn {
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #374151;
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 0.88rem;
    cursor: pointer;
}

.ml-detail-action-btn:hover:not(:disabled) {
    background: #f9fafb;
}

.ml-detail-action-btn-danger {
    border-color: #f5c2c7;
    background: #fff1f2;
    color: #dc3545;
}

.ml-detail-action-btn-danger:hover:not(:disabled) {
    background: #ffe1e5;
}

.ml-detail-action-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.ml-detail-loading {
    color: #6b7280;
    font-size: 0.9rem;
    text-align: center;
    padding: 24px 0;
}

/* === Main page (sticky footer) === */
.ml-main-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.ml-main-page > .container {
    flex: 1 1 auto;
}

/* === Login page (compact layout) === */
.ml-login-page {
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.ml-login-wrapper {
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 16px 40px;
    flex: 1 1 auto;
}
.ml-login-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 4px;
    text-align: center;
}
.ml-login-subtitle {
    font-size: 0.78rem;
    color: #6b7280;
    text-align: center;
    margin-bottom: 18px;
    line-height: 1.5;
}
.ml-login-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
    padding: 18px 20px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.04);
}
.ml-login-card + .ml-login-card {
    margin-top: 14px;
}
.ml-login-section + .ml-login-section {
    margin-top: 4px;
}
.ml-login-divider {
    margin: 18px -20px;
    border: 0;
    border-top: 1px solid #e5e7eb;
    opacity: 1;
}
.ml-login-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ml-login-card-title .ml-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #0d6efd;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
}
.ml-login-form-label {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: #374151;
}
.ml-login-input {
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.85rem;
}
.ml-password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
}
.ml-password-toggle:hover,
.ml-password-toggle:focus-visible {
    color: #374151;
}
.ml-password-toggle:focus-visible {
    outline: 2px solid rgba(13, 110, 253, 0.35);
    outline-offset: 1px;
}
.ml-login-hint {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 6px;
    line-height: 1.5;
}
.ml-login-hint code {
    background: #f3f4f6;
    color: #1f2937;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.75rem;
}
.ml-login-error {
    font-size: 0.78rem;
    color: #dc2626;
    margin-top: 6px;
    min-height: 1em;
}
.ml-login-server-msg {
    font-size: 0.82rem;
    margin-top: 12px;
    margin-bottom: 0;
    padding: 8px 12px;
}
.ml-login-submit {
    margin-top: 12px;
    font-weight: 500;
    padding: 8px 0;
}
.ml-guide-list {
    margin: 0;
    padding-left: 0;
    list-style: none;
    counter-reset: guide;
}
.ml-guide-list > li {
    position: relative;
    padding: 6px 0 6px 28px;
    font-size: 0.82rem;
    line-height: 1.55;
    color: #374151;
    border-bottom: 1px dashed #f3f4f6;
}
.ml-guide-list > li:last-child {
    border-bottom: none;
}
.ml-guide-list > li::before {
    counter-increment: guide;
    content: counter(guide);
    position: absolute;
    left: 0;
    top: 6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #e0e7ff;
    color: #3730a3;
    font-size: 0.72rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ml-guide-list code {
    background: #f3f4f6;
    color: #1f2937;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.78rem;
    word-break: break-all;
}
.ml-guide-method + .ml-guide-method {
    margin-top: 14px;
}
.ml-guide-method-title {
    margin: 0 0 4px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #312e81;
}
.ml-guide-note {
    margin-top: 10px;
    padding: 8px 10px;
    background: #fffbeb;
    border-left: 3px solid #f59e0b;
    border-radius: 4px;
    color: #92400e;
    font-size: 0.78rem;
    line-height: 1.5;
}

/* === Welcome banner on the main page === */
.ml-welcome-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 16px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
}
.ml-welcome-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    font-size: 0.85rem;
    color: #374151;
    min-width: 0;
}
.ml-welcome-greeting {
    font-weight: 600;
    color: #111827;
}
.ml-welcome-name {
    color: #0d6efd;
}
.ml-welcome-meta {
    color: #6b7280;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.ml-welcome-meta-label {
    background: #e0e7ff;
    color: #3730a3;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
}
.ml-welcome-token-expiring {
    color: #dc3545;
    font-weight: 600;
}

/* === Login page: admin toggle + admin login card === */
.ml-admin-toggle-bar {
    margin-top: 14px;
    text-align: center;
}
.ml-admin-toggle {
    font-size: 0.8rem;
    color: #6b7280;
    padding: 2px 6px;
}
.ml-admin-toggle:hover {
    color: #374151;
}
.ml-admin-back {
    font-size: 0.8rem;
    color: #6b7280;
    padding: 4px 0 0;
    text-decoration: none;
}
.ml-step-num-admin {
    background: #374151 !important;
}

/* === Admin console page === */
.ml-admin-page {
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.ml-admin-wrapper {
    max-width: 1040px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 16px 40px;
    flex: 1 1 auto;
}
.ml-admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.ml-admin-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}
.ml-admin-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
    padding: 18px 20px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.04);
}
.ml-admin-card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    margin-bottom: 14px;
}
.ml-admin-card-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
}
/* Count badge beside the card title — mirrors the main page's
   "总有效次数：N" stat: a gray label with the count in blue/bold. */
.ml-admin-title-count {
    margin-left: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #6b7280;
    vertical-align: middle;
}
.ml-admin-title-num {
    color: #0d6efd;
    font-weight: 700;
    margin: 0 2px;
}
/* Pure front-end sequence-number column (not part of whitelist data). */
.ml-admin-th-seq {
    text-align: center;
    color: #94a3b8;
}
.ml-admin-seq {
    text-align: center;
    color: #94a3b8;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.78rem;
}
.ml-admin-card-actions {
    /* Take the full row width so the 6 toolbar buttons have slack to sit on
       one line. nowrap guarantees a single line (flex-wrap: wrap wraps the
       6th button to a second row at a sub-pixel boundary even when the row
       is plenty wide); on a too-narrow viewport the header's own flex-wrap
       moves the whole toolbar below the title instead. */
    flex: 1 1 auto;
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 8px;
}
/* Uniform sizing so every toolbar button lines up regardless of label.
   nowrap keeps labels on one line; min-width makes short labels as wide as
   long ones so the whole row is one consistent block. We deliberately do
   NOT make these flex containers — a flex button with CJK text can shrink
   its text flex-item to one char and re-wrap. Bootstrap's inline-block +
   text-align:center already centres the label. */
.ml-admin-btn {
    min-width: 108px;
    white-space: nowrap;
    /* Override the global ".btn-primary { margin-top: 20px }" legacy rule,
       which otherwise drops every solid-blue button 20px below its siblings
       (the toolbar "保存" and the per-row "保存" in edit mode). */
    margin-top: 0;
}
.ml-admin-table-scroll {
    overflow-x: auto;
    border: 1px solid #f1f5f9;
    border-radius: 8px;
}
.ml-admin-table-scroll th {
    background: #f8fafc;
    font-size: 0.78rem;
    color: #475569;
    white-space: nowrap;
}
.ml-admin-table-scroll td {
    font-size: 0.82rem;
    vertical-align: middle;
}
.ml-admin-add-row {
    text-align: left;
    padding: 10px 8px !important;
    border-top: 2px solid #f1f5f9;
}
.ml-admin-text-cell {
    font-family: "JetBrains Mono", Consolas, monospace;
    color: #1f2937;
    word-break: break-all;
}
.ml-admin-pw-cell {
    color: #111827;
}
/* Row action buttons: equal width, sit on one line, wrap gracefully. */
.ml-admin-actions {
    /* nowrap keeps the 3 row buttons on a single line; if the cell is too
       narrow the table's own horizontal scroll kicks in instead. */
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 4px;
}
.ml-admin-btn-row {
    min-width: 80px;
    white-space: nowrap;
    /* Same legacy ".btn-primary margin-top:20px" override for row buttons
       (the per-row "保存" is btn-primary and would otherwise sit a line low). */
    margin-top: 0;
}
/* Edit-mode + dirty row highlights so pending changes are visible at a glance. */
.ml-admin-row-editing {
    background: #eff6ff;
}
.ml-admin-row-editing td {
    background: #eff6ff;
}
.ml-admin-row-dirty {
    background: #fffbeb;
}
.ml-admin-row-dirty td {
    background: #fffbeb;
}
.ml-admin-input {
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.8rem;
}
.ml-admin-raw-editor {
    display: flex;
    align-items: stretch;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    overflow: hidden;
    background: #fff;
}
.ml-admin-raw-editor:focus-within {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.18);
}
.ml-admin-raw-editor.ml-admin-raw-invalid {
    border-color: #dc2626;
    box-shadow: 0 0 0 0.2rem rgba(220, 38, 38, 0.18);
}
.ml-admin-raw-gutter {
    flex: 0 0 auto;
    margin: 0;
    padding: 0.375rem 0.6rem;
    background: #f8fafc;
    color: #94a3b8;
    border-right: 1px solid #e5e7eb;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    text-align: right;
    user-select: none;
    overflow: hidden;
    white-space: pre;
    min-width: 2.6em;
    tab-size: 1;
}
.ml-admin-raw-textarea {
    flex: 1 1 auto;
    width: 100%;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    min-height: 60vh;
    resize: vertical;
}
.ml-admin-raw-textarea:focus {
    outline: none;
}
/* Live JSON grammar status hint (debounced). */
.ml-admin-raw-grammar {
    margin-top: 6px;
    font-size: 0.78rem;
    font-family: "JetBrains Mono", Consolas, monospace;
    line-height: 1.4;
    word-break: break-all;
}
.ml-admin-raw-grammar-ok {
    color: #16a34a;
}
.ml-admin-raw-grammar-err {
    color: #dc2626;
}
.ml-admin-raw-hint {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 6px;
}
.ml-admin-status {
    font-size: 0.82rem;
    margin-top: 14px;
    margin-bottom: 0;
    padding: 8px 12px;
}
.ml-admin-count {
    margin-top: 8px;
    font-size: 0.78rem;
}
.ml-admin-note {
    margin-top: 14px;
    font-size: 0.75rem;
    color: #6b7280;
    line-height: 1.55;
}

/* === Save / Discard / Cancel modal (dirty-edit guard) === */
.ml-admin-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
}
.ml-admin-modal-box {
    background: #ffffff;
    border-radius: 12px;
    padding: 22px 22px 14px;
    max-width: 380px;
    width: calc(100% - 32px);
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.22);
    text-align: center;
}
.ml-admin-modal-text {
    font-size: 0.9rem;
    color: #374151;
    margin-bottom: 12px;
    line-height: 1.55;
}
.ml-admin-modal-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    justify-content: center;
}
/* Shorter footer buttons inside the popups only (Bootstrap btn-sm default
   vertical padding is taller than the rest of the trimmed footer). */
.ml-admin-modal-actions .ml-admin-btn,
.ml-admin-share-actions .ml-admin-btn {
    padding-top: 3px;
    padding-bottom: 3px;
}

/* === Share column + share card === */
.ml-admin-th-share {
    text-align: center;
    color: #475569;
}
.ml-admin-share-col {
    text-align: center;
}
/* === Enabled/disabled status column === */
.ml-admin-status-col {
    white-space: nowrap;
}
.ml-admin-status-col .form-check-input {
    /* Bootstrap switches default to pointer-events-friendly sizing but a
       plain cursor; make the affordance obvious next to the badge. */
    cursor: pointer;
    flex: 0 0 auto;
    margin-right: 0;
}
.ml-admin-share-btn {
    /* Icon button: tight padding, no min-width (it has no .ml-admin-btn), so
       the column stays narrow. */
    min-width: 0;
    padding: 2px 8px;
    line-height: 1;
    margin-top: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.ml-admin-share-btn svg {
    display: block;
}
.ml-admin-share-box {
    /* Drop the default modal padding so the green header clips to the rounded
       top corners; each section manages its own padding. Wider than the 380px
       default so the one-line JSON fits. */
    max-width: 480px;
    padding: 0;
    overflow: hidden;
    text-align: left;
}
.ml-admin-share-card {
    display: flex;
    flex-direction: column;
}
.ml-admin-share-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    color: #1f2937;
}
.ml-admin-share-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    color: #64748b;
}
.ml-admin-share-title {
    flex: 1 1 auto;
    font-size: 1.02rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: 0.01em;
}
.ml-admin-share-close-x {
    flex: 0 0 auto;
    background: #f1f5f9;
    border: 0;
    color: #64748b;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.ml-admin-share-close-x:hover {
    background: #e2e8f0;
    color: #1f2937;
}
.ml-admin-share-body {
    padding: 6px 16px 2px;
}
.ml-admin-share-line {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid #f1f5f9;
}
.ml-admin-share-line:last-child {
    border-bottom: 0;
}
.ml-admin-share-label {
    flex: 0 0 56px;
    text-align: center;
    font-size: 0.74rem;
    font-weight: 600;
    color: #475569;
    background: #f1f5f9;
    border-radius: 999px;
    padding: 3px 0;
}
.ml-admin-share-value {
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.92rem;
    color: #0f172a;
    word-break: break-all;
}
/* Click-to-copy rows: the whole line is a target, mirroring the JSON code
   box below (hover tint + "点击复制" hint that flashes "已复制 ✓"). */
.ml-admin-share-copyline {
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s;
}
.ml-admin-share-copyline:hover {
    background: #eef2ff;
}
.ml-admin-share-copy-hint {
    flex: 0 0 auto;
    margin-left: auto;
    padding-left: 12px;
    font-size: 0.72rem;
    color: #94a3b8;
    white-space: nowrap;
    transition: color 0.15s;
}
/* :not(.ml-copied-done) keeps the green flash visible while the pointer is
   still over the line — the plain hover selector would out-specify it. */
.ml-admin-share-copyline:hover .ml-admin-share-copy-hint:not(.ml-copied-done) {
    color: #4f46e5;
}
/* Light code box with a small "JSON" tag header, consistent with the page. */
.ml-admin-share-code-wrap {
    margin: 10px 16px 0;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #f8fafc;
}
.ml-admin-share-code-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 12px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 0.72rem;
    border-bottom: 1px solid #e5e7eb;
}
.ml-admin-share-code-tag {
    font-family: "JetBrains Mono", Consolas, monospace;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #475569;
}
.ml-admin-share-code-hint {
    opacity: 0.85;
}
.ml-admin-share-code {
    margin: 0;
    padding: 11px 12px;
    background: #f8fafc;
    color: #0f172a;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    cursor: pointer;
    transition: background 0.15s;
}
.ml-admin-share-code:hover {
    background: #eef2ff;
}
.ml-admin-share-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    justify-content: flex-end;
    padding: 10px 16px 12px;
}

/* === CORS banner: popup-style warning dialog ============================= */
/* 弹窗样式：a centered modal — the fixed card sits at the exact center of
 * the viewport over a dark backdrop (#ml-cors-overlay reuses the .overlay
 * base class) that masks all page content; warning-tinted header strip
 * over a white body, 12px radius + shadow (same visual language as the
 * page's custom-alert dialogs). z-index: backdrop 1250 / card 1260 —
 * above the fixed summary card (1200), below the detail/alert dialog
 * layer (1290+/2000+) so genuine popups still paint above it. */
#ml-cors-overlay {
    z-index: 1250;
}
.ml-cors-banner-wrap {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1260;
    width: min(780px, calc(100vw - 24px));
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}
.ml-cors-banner {
    background: #ffffff;
    border: 1px solid #f0d28a;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
    overflow: hidden;
}
.ml-cors-banner-head {
    display: flex;
    align-items: center;
    justify-content: space-between; /* title vs the login page's close × */
    gap: 12px;
    padding: 12px 16px;
    background: #fff3cd; /* Bootstrap alert-warning tint */
    border-bottom: 1px solid #f0d28a;
}
.ml-cors-banner-title {
    color: #664d03; /* Bootstrap alert-warning text */
    font-size: 1.15rem;
    line-height: 1.4;
}
/* Close × (login page only — the main page's modal is non-dismissible).
 * Fully local styling with a text × glyph (same pattern as
 * .custom-alert-close): the button must remain visible/clickable even if
 * the remote Bootstrap CDN CSS fails to load — e.g. first visit while
 * offline, when the "network" branch shows this very modal. */
.ml-cors-banner-close {
    flex-shrink: 0;
    align-self: flex-start;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #664d03; /* Bootstrap alert-warning text */
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.65;
    transition: opacity 0.15s ease, background 0.15s ease;
}
.ml-cors-banner-close:hover {
    opacity: 1;
    background: rgba(102, 77, 3, 0.12);
}
.ml-cors-banner-body {
    padding: 12px 16px 14px;
    color: #495057;
}
/* Hint text renders one sentence per line (ml_show_cors_banner splits on
 * \n); a little breathing room between the lines. */
.ml-cors-banner-line {
    margin-bottom: 6px;
}
.ml-cors-banner-line:last-child {
    margin-bottom: 0;
}


/* Command boxes: mirror the admin console's share-card code box
 * (.ml-admin-share-code-*): a header row (mono tag + 点击复制 hint) over a
 * clickable code line; clicking the code copies it and flashes the hint to
 * 已复制 ✓ (see templates/index.html ml_copy_cors_command).
 * Responsive 2-up grid; collapses to one column on narrow screens. */
.ml-cors-cmd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 8px;
    margin-top: 8px;
}
.ml-cors-cmd-box {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #f8fafc;
    min-width: 0;
}
.ml-cors-cmd-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 10px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 0.72rem;
    border-bottom: 1px solid #e5e7eb;
}
.ml-cors-cmd-tag {
    font-family: "JetBrains Mono", Consolas, monospace;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #475569;
}
.ml-cors-cmd-hint {
    opacity: 0.85;
}
/* Green flash while the copy feedback (已复制 ✓) is showing. One generic
   class shared by every click-to-copy target (CORS command-box hints, admin
   share-card hints/buttons) — toggled by ml_copy_with_flash. */
.ml-copied-done {
    color: #16a34a;
    font-weight: 600;
    opacity: 1;
}
/* The flashed element is usually a hint span, but the share card's JSON
   copy button flashes too — keep its white label readable on btn-primary. */
.btn-primary.ml-copied-done {
    color: #fff;
}
.ml-cors-cmd {
    display: block;
    margin: 0;
    padding: 8px 10px;
    background: #f8fafc;
    color: #0f172a;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    cursor: pointer;
    transition: background 0.15s;
}
.ml-cors-cmd:hover {
    background: #eef2ff;
}
