/* ============================================================
   变电工作台 — 浅色清爽风格（移动端优先）
   ============================================================ */

/* === 设计变量 === */
:root {
    --primary: #4f8ef7;
    --primary-hover: #3a7ae0;
    --primary-light: rgba(79, 142, 247, 0.10);
    --success: #22c55e;
    --success-light: #f0fdf4;
    --success-bg: rgba(34, 197, 94, 0.10);
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --warning-bg: rgba(245, 158, 11, 0.10);
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --danger-bg: rgba(239, 68, 68, 0.10);
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --bg-main: #f5f7fa;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --top-bar-h: 52px;
    --tab-bar-h: 60px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* === 深色主题 === */
body.dark {
    --bg-main: #0f172a;
    --bg-card: rgba(255, 255, 255, 0.06);
    --bg-hover: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.10);
    --border-light: rgba(255, 255, 255, 0.06);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --primary-light: rgba(79, 142, 247, 0.18);
    --success-light: rgba(34, 197, 94, 0.12);
    --success-bg: rgba(34, 197, 94, 0.15);
    --warning-light: rgba(245, 158, 11, 0.12);
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger-light: rgba(239, 68, 68, 0.12);
    --danger-bg: rgba(239, 68, 68, 0.15);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* === 基础重置 === */
* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
                 "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 15px;
    min-height: 100vh;
    overflow-x: hidden;
}

/* === 顶部导航栏 === */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--top-bar-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-bar-left #top-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.clock {
    font-size: 12px;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
}

.btn-icon {
    border: none;
    background: none;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

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

/* === 主内容区 === */
.main-content {
    margin-top: var(--top-bar-h);
    margin-bottom: calc(var(--tab-bar-h) + var(--safe-bottom));
    min-height: calc(100vh - var(--top-bar-h) - var(--tab-bar-h));
    padding: 16px;
}

/* === 视图切换 === */
.view { display: none; }
.view.active { display: block; }

/* === 底部 Tab 栏 === */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--tab-bar-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 0;
    border: none;
    background: none;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.tab-item.active {
    color: var(--primary);
}

.tab-icon {
    font-size: 20px;
    line-height: 1;
}

.tab-label {
    font-size: 11px;
    font-weight: 500;
}

/* === 问候语 === */
.greeting {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

/* === 区域标题 === */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.section-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.section-actions {
    display: flex;
    gap: 8px;
}

/* === 批量删除栏 === */
.batch-delete-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    animation: fadeIn 0.2s ease;
}

.batch-count {
    font-size: 13px;
    color: var(--text-secondary);
}

/* === 卡片删除按钮 === */
.card-delete-btn {
    border: none;
    background: none;
    color: var(--text-tertiary);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius-xs);
    transition: all 0.15s;
    flex-shrink: 0;
    line-height: 1;
}

.card-delete-btn:hover {
    color: var(--danger);
    background: var(--danger-light);
}

.card-delete-btn.confirm-delete {
    color: #fff;
    background: var(--danger);
    font-size: 11px;
    padding: 4px 8px;
}

/* 批量选择复选框 */
.batch-check {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.batch-check input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* === 已删除项恢复区 === */
.removed-section {
    margin-top: 20px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.removed-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.removed-label {
    font-size: 12px;
    color: var(--text-tertiary);
}

.removed-items-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.removed-item-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--gray-100);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.removed-item-name {
    cursor: pointer;
}

.removed-item-name:hover {
    color: var(--primary);
}

.restore-icon {
    font-size: 10px;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: color 0.15s;
}

.restore-icon:hover {
    color: var(--success);
}

.permanent-delete-icon {
    font-size: 10px;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: color 0.15s;
    margin-left: 2px;
}

.permanent-delete-icon:hover {
    color: var(--danger);
}

/* === 卡片列表 === */
.card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* === 概览卡片 === */
.overview-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.overview-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

.overview-card:active {
    transform: scale(0.98);
}

/* 拖拽手柄 */
.drag-handle {
    cursor: grab;
    color: var(--text-tertiary);
    font-size: 18px;
    padding: 4px;
    user-select: none;
    touch-action: none;
    flex-shrink: 0;
}

.drag-handle:active {
    cursor: grabbing;
    color: var(--primary);
}

/* 拖拽占位 */
.sortable-ghost {
    opacity: 0.4;
    background: var(--primary-light) !important;
    border: 2px dashed var(--primary) !important;
}

.overview-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.overview-card-icon.status-all { background: var(--success-bg); color: var(--success); }
.overview-card-icon.status-partial { background: var(--warning-bg); color: var(--warning); }
.overview-card-icon.status-none { background: var(--gray-100); color: var(--text-tertiary); }

.overview-card-body {
    flex: 1;
    min-width: 0;
}

.overview-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.overview-card-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

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

.progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.progress-fill.fill-all { background: var(--success); }
.progress-fill.fill-partial { background: var(--warning); }

.overview-card-arrow {
    color: var(--text-tertiary);
    font-size: 16px;
    flex-shrink: 0;
}

/* === 表单 === */
.form-group {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color 0.15s;
    -webkit-appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* 站点勾选列表 */
.station-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.station-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    transition: all 0.15s;
}

.station-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    width: 70px;
    flex-shrink: 0;
}

.station-actions {
    display: flex;
    gap: 6px;
    flex: 1;
    justify-content: flex-end;
}

.status-pill {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.status-pill:hover {
    border-color: var(--gray-300);
}

.status-pill.active-todo {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger);
}

.status-pill.active-done {
    background: var(--success-bg);
    color: var(--success);
    border-color: var(--success);
}

.status-pill.active-na {
    background: var(--gray-100);
    color: var(--text-tertiary);
    border-color: var(--gray-300);
}

/* 已完成时的日期+姓名输入 */
.station-done-extra {
    display: none;
    flex-basis: 100%;
    padding-top: 8px;
    gap: 6px;
}

.station-done-extra.show {
    display: flex;
}

.station-done-extra input {
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    width: 70px;
}

.station-done-extra input:focus {
    outline: none;
    border-color: var(--primary);
}

.station-done-extra input.name-input {
    width: 60px;
}

/* === 详情页头 === */
.detail-header {
    margin-bottom: 16px;
}

.detail-header h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.detail-date-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-date-row label {
    font-size: 13px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.detail-date {
    font-size: 13px;
    color: var(--text-secondary);
}

/* === 保存栏 === */
.save-bar {
    position: fixed;
    bottom: calc(var(--tab-bar-h) + var(--safe-bottom));
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 90;
}

#view-item-detail .save-bar {
    bottom: 0;
    margin-bottom: var(--safe-bottom);
}

/* === 按钮 === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

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

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

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

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

.btn-danger {
    color: var(--danger);
    border-color: var(--danger);
    background: var(--danger-light);
}

.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

/* === 历史记录卡片 === */
.history-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.history-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
}

.history-card-header:hover {
    background: var(--bg-hover);
}

.history-date {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.history-card-actions {
    display: flex;
    gap: 6px;
}

.history-summary {
    padding: 0 16px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.history-detail {
    display: none;
    padding: 0 16px 14px;
    border-top: 1px solid var(--border-light);
}

.history-detail.open {
    display: block;
    padding-top: 12px;
}

.history-detail-row {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 3px 0;
    line-height: 1.6;
}

.history-detail-row .val-done { color: var(--success); font-weight: 500; }
.history-detail-row .val-todo { color: var(--danger); font-weight: 500; }
.history-detail-row .val-na { color: var(--text-tertiary); }

/* === 空状态 === */
.empty-state {
    text-align: center;
    color: var(--text-tertiary);
    padding: 48px 16px;
    font-size: 14px;
}

/* === 弹窗 === */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-mask {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 24px 20px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
}

.modal-content h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    justify-content: flex-end;
}

/* === Toast === */
.toast {
    position: fixed;
    bottom: calc(var(--tab-bar-h) + var(--safe-bottom) + 16px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--gray-800);
    color: #f8fafc;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
    z-index: 300;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

body.dark .toast {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid var(--border);
}

/* === 动画 === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.card-list > * {
    animation: fadeIn 0.2s ease;
}

/* === 桌面端适配（≥768px）=== */
@media (min-width: 768px) {
    .main-content {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
        padding: 24px;
    }

    .top-bar {
        justify-content: center;
    }

    .top-bar-left {
        position: absolute;
        left: 24px;
    }

    .tab-bar {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: var(--radius) var(--radius) 0 0;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }

    .save-bar {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
    }

    .modal {
        align-items: center;
    }

    .modal-content {
        border-radius: var(--radius);
        max-width: 400px;
    }

    .station-row {
        padding: 12px 18px;
    }

    .station-name {
        width: 80px;
    }
}
