/* ================================================================
   DC运维周例会管理系统 — 飞书式紧凑设计
   原则：信息密度 > 视觉效果，列表 > 卡片，对齐 > 装饰
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    /* 主色 */
    --primary: #3370ff;
    --primary-hover: #2b5fd9;
    --primary-soft: #e1eaff;

    /* 功能色 */
    --success: #52c41a;
    --success-soft: #f6ffed;
    --warning: #faad14;
    --warning-soft: #fffbe6;
    --danger: #f5222d;
    --danger-soft: #fff2f0;
    --info: #1677ff;
    --info-soft: #e6f7ff;

    /* 中性色 — 飞书风格 */
    --n-900: #1f2329;
    --n-800: #2f353f;
    --n-700: #414753;
    --n-600: #646a73;
    --n-500: #8f959e;
    --n-400: #bbbfc4;
    --n-300: #dee0e3;
    --n-200: #e5e6eb;
    --n-100: #f2f3f5;
    --n-50: #f5f6f7;
    --n-0: #ffffff;

    /* 尺寸 */
    --sidebar-w: 220px;
    --radius: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --list-h: 52px;

    /* 字体 */
    --mono: 'JetBrains Mono', ui-monospace, monospace;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--n-0);
    color: var(--n-900);
    font-size: 14px;
    line-height: 1.5;
}

/* ================================================================
   LAYOUT
   ================================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--n-900);
    color: var(--n-400);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    padding: 20px 0;
}

.sidebar-brand {
    padding: 0 20px 24px;
    font-size: 16px;
    font-weight: 700;
    color: var(--n-0);
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 28px;
    height: 28px;
    background: var(--primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

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

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--n-400);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.sidebar-nav a:hover {
    background: var(--n-800);
    color: var(--n-200);
}

.sidebar-nav a.active {
    background: var(--n-800);
    color: var(--n-0);
    font-weight: 600;
}

.nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.sidebar-user {
    padding: 12px 16px;
    margin: 0 12px;
    border-top: 1px solid var(--n-800);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-user .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}
.sidebar-user .user-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.sidebar-user .user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--n-200);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user .user-role {
    font-size: 11px;
    color: var(--n-500);
}
.sidebar-user .logout-btn {
    padding: 4px 8px;
    background: transparent;
    border: none;
    color: var(--n-500);
    font-size: 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
    white-space: nowrap;
}
.sidebar-user .logout-btn:hover {
    background: var(--n-800);
    color: var(--n-200);
}

/* ── Main ── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    padding: 24px 32px 48px;
    max-width: 1200px;
}

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

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--n-900);
    line-height: 1.3;
    letter-spacing: -0.3px;
}

.page-header .subtitle {
    color: var(--n-500);
    font-size: 13px;
    margin-top: 4px;
}

/* ================================================================
   INLINE STATS (飞书式紧凑统计)
   ================================================================ */
.inline-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    font-size: 13px;
}

.inline-stats .stat {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: var(--radius);
    transition: background 0.15s;
    color: var(--n-600);
}

.inline-stats .stat:hover { background: var(--n-50); }
.inline-stats .stat.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.inline-stats .stat-num {
    font-family: var(--mono);
    font-weight: 600;
    font-size: 15px;
}

.inline-stats .stat-label { font-size: 13px; }

/* ================================================================
   TOOLBAR (搜索 + 筛选 + 操作)
   ================================================================ */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--n-200);
    margin-bottom: 0;
}

.toolbar-search {
    position: relative;
    flex: 1;
    max-width: 280px;
}

.toolbar-search input {
    width: 100%;
    padding: 7px 12px 7px 32px;
    border: 1px solid var(--n-200);
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--n-0);
    transition: all 0.15s;
}

.toolbar-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(51,112,255,0.12);
}

.toolbar-search::before {
    content: "";
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238f959e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat center;
    opacity: 0.7;
}

.toolbar .filter-select {
    padding: 7px 28px 7px 10px;
    border: 1px solid var(--n-200);
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--n-0);
    color: var(--n-700);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%238f959e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    cursor: pointer;
    transition: all 0.15s;
}

.toolbar .filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(51,112,255,0.12);
}

.toolbar-spacer { flex: 1; }

/* ================================================================
   BUTTONS (扁平)
   ================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: var(--radius);
    border: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    line-height: 1.4;
    white-space: nowrap;
}

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

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { background: #389e0d; }

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

.btn-ghost {
    background: transparent;
    color: var(--n-600);
    border: 1px solid var(--n-200);
}
.btn-ghost:hover { background: var(--n-50); }

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

/* ================================================================
   TASK LIST (核心：飞书式列表)
   ================================================================ */
.task-list {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: hidden;
}

.task-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    height: var(--list-h);
    border-bottom: 1px solid var(--n-200);
    cursor: pointer;
    transition: background 0.1s;
    position: relative;
    min-width: 0;
    overflow: hidden;
}

.task-row:hover { background: var(--n-50); }
.task-row:last-child { border-bottom: none; }

/* 左侧状态色条 */
.task-row::before {
    content: '';
    position: absolute;
    left: 0; top: 12px; bottom: 12px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: transparent;
}

.task-row.status-delayed::before { background: var(--danger); }
.task-row.status-ontime::before { background: var(--success); }
.task-row.status-warning::before { background: var(--warning); }

/* 复选框 */
.task-check {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
    flex-shrink: 0;
}

/* 任务名 */
.task-name {
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
    width: 0;
    display: block;
    font-weight: 500;
    font-size: 14px;
    color: var(--n-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-row.completed .task-name {
    text-decoration: line-through;
    color: var(--n-400);
}

/* 元信息列 — 固定宽度，纵向对齐 */
.task-meta {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-shrink: 0;
}

.task-meta-col {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--n-500);
    white-space: nowrap;
}

.task-meta-col.w-executor { width: 90px; }
.task-meta-col.w-date { width: 90px; }
.task-meta-col.w-week { width: 70px; }

/* 标签 */
.task-tag {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    line-height: 18px;
}

.tag-doing { background: var(--info-soft); color: var(--info); }
.tag-done { background: var(--success-soft); color: var(--success); }
.tag-delay { background: var(--danger-soft); color: var(--danger); }
.tag-warn { background: var(--warning-soft); color: #d48806; }
.tag-gray { background: var(--n-100); color: var(--n-600); }

/* 行操作 */
.task-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
    margin-left: 8px;
}

.task-row:hover .task-actions { opacity: 1; }

/* ================================================================
   CARD (仅用于表单、配置面板)
   ================================================================ */
.card {
    background: var(--n-0);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--n-200);
}

.card h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--n-900);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--n-200);
}

/* ================================================================
   FORM
   ================================================================ */
.form-group {
    margin-bottom: 16px;
}

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

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--n-200);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--n-900);
    background: var(--n-0);
    transition: all 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(51,112,255,0.12);
}

.form-control::placeholder { color: var(--n-400); }

textarea.form-control {
    min-height: 100px;
    resize: vertical;
    line-height: 1.6;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%238f959e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

/* ================================================================
   MODAL
   ================================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal {
    background: var(--n-0);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--n-400);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: all 0.15s;
}

.modal-close:hover { background: var(--n-100); color: var(--n-700); }

.modal-body { padding: 20px 24px; }
.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--n-200);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ================================================================
   LOADING & EMPTY
   ================================================================ */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--n-400);
    font-size: 14px;
}

.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--n-400);
    font-size: 14px;
}

/* ================================================================
   AI RESULTS
   ================================================================ */
.ai-result {
    background: var(--n-50);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-top: 16px;
    border: 1px solid var(--n-200);
    font-size: 13px;
}

.ai-result h3 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 10px;
}

.ai-result h4 {
    font-size: 13px;
    font-weight: 700;
    margin: 12px 0 6px;
    color: var(--n-700);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--n-200);
}

.ai-result-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--n-200);
    color: var(--n-700);
}
.ai-result-item:last-child { border-bottom: none; }

/* ================================================================
   HEATMAP (折叠式)
   ================================================================ */
.heatmap-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
}

.heatmap-grid-inline {
    display: flex;
    gap: 3px;
}

.heatmap-cell-inline {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background: var(--n-200);
    cursor: pointer;
    transition: transform 0.1s;
}

.heatmap-cell-inline:hover { transform: scale(1.2); }
.heatmap-cell-inline.l1 { background: #b7eb8f; }
.heatmap-cell-inline.l2 { background: #95de64; }
.heatmap-cell-inline.l3 { background: #73d13d; }
.heatmap-cell-inline.l4 { background: #52c41a; }

/* ================================================================
   DETAIL MODAL (task detail)
   ================================================================ */
.detail-modal { max-width: 900px; }
.detail-modal-body { display: grid; grid-template-columns: 320px 1fr; gap: 0; padding: 0; min-height: 420px; }
.detail-left { padding: 24px; border-right: 1px solid var(--n-200); display: flex; flex-direction: column; gap: 16px; }
.detail-right { padding: 24px; background: var(--n-50); display: flex; flex-direction: column; gap: 16px; }

.detail-task-name { font-size: 16px; font-weight: 700; line-height: 1.4; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--n-200); }

.detail-meta-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; font-size: 13px; }
.detail-meta-grid .label { color: var(--n-500); font-weight: 500; white-space: nowrap; }
.detail-meta-grid .value { color: var(--n-700); font-weight: 500; }
.detail-meta-grid .value.delay { color: var(--danger); font-weight: 600; background: var(--danger-soft); padding: 1px 8px; border-radius: 4px; font-size: 12px; width: fit-content; }
.detail-meta-grid .value.ontime { color: var(--success); font-weight: 600; background: var(--success-soft); padding: 1px 8px; border-radius: 4px; font-size: 12px; width: fit-content; }
.detail-meta-grid .edit-btn { margin-left: 6px; padding: 1px 8px; font-size: 12px; background: var(--n-100); border: none; border-radius: 4px; color: var(--n-500); cursor: pointer; }
.detail-meta-grid .edit-btn:hover { background: var(--n-200); color: var(--n-700); }

.detail-section-title { font-size: 12px; font-weight: 700; color: var(--n-500); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.detail-progress-box { background: var(--n-0); border-radius: var(--radius); padding: 12px 14px; border: 1px solid var(--n-200); font-size: 13px; color: var(--n-700); line-height: 1.6; max-height: 120px; overflow-y: auto; white-space: pre-wrap; }
.detail-progress-box:empty::before { content: '暂无进展记录'; color: var(--n-400); }

.progress-form { margin-top: 4px; }
.progress-form textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--n-200); border-radius: var(--radius); font-size: 13px; resize: vertical; min-height: 70px; background: var(--n-0); transition: all 0.15s; }
.progress-form textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(51,112,255,0.12); }
.progress-form-actions { display: flex; gap: 8px; margin-top: 10px; }

.plan-date-editor { display: none; align-items: center; gap: 8px; margin-top: 8px; padding: 8px; background: var(--n-50); border-radius: var(--radius); }
.plan-date-editor.show { display: flex; }
.plan-date-editor input { padding: 5px 8px; border: 1px solid var(--n-200); border-radius: var(--radius); font-size: 13px; }

/* gantt */
.gantt-container { margin-bottom: 4px; }
.gantt-title { font-size: 13px; font-weight: 700; color: var(--n-700); margin-bottom: 12px; }
.gantt-scroll { overflow-x: auto; padding-bottom: 8px; }
.gantt-timeline { display: flex; gap: 3px; min-width: max-content; }
.gantt-week { flex: 0 0 52px; text-align: center; }
.gantt-week-header { font-size: 11px; color: var(--n-500); padding: 4px 0; border-bottom: 2px solid var(--n-200); margin-bottom: 10px; font-weight: 500; }
.gantt-week.current .gantt-week-header { color: var(--primary); border-bottom-color: var(--primary); background: var(--primary-soft); border-radius: 4px 4px 0 0; font-weight: 700; }
.gantt-week.plan .gantt-week-header { color: var(--success); font-weight: 700; }
.gantt-track { height: 36px; display: flex; align-items: center; justify-content: center; position: relative; background: var(--n-0); border-radius: var(--radius); }
.gantt-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--primary); border: 2px solid white; box-shadow: 0 0 0 2px var(--primary); cursor: pointer; transition: transform 0.15s; position: relative; z-index: 2; }
.gantt-dot:hover { transform: scale(1.3); }
.gantt-dot.active { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.gantt-line { position: absolute; top: 50%; left: 26px; right: 26px; height: 2px; background: var(--n-200); z-index: 0; }
.gantt-plan-marker { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--success); z-index: 2; }
.gantt-plan-marker::after { content: '计划'; position: absolute; top: -16px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--success); white-space: nowrap; font-weight: 600; background: var(--success-soft); padding: 0 4px; border-radius: 3px; }

/* history */
.history-list { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.history-item { padding: 10px 12px; border-radius: var(--radius); background: var(--n-0); font-size: 13px; border-left: 2px solid var(--n-300); }
.history-item.human { border-left-color: var(--primary); }
.history-item.ai { border-left-color: var(--info); }
.history-item.meeting { border-left-color: var(--warning); }
.history-item-header { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 12px; color: var(--n-400); }
.history-item-text { color: var(--n-700); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; }

/* ================================================================
   REPORT / MEETING LIST
   ================================================================ */
.simple-list-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--n-200);
    transition: background 0.1s;
}
.simple-list-item:hover { background: var(--n-50); }
.simple-list-item:last-child { border-bottom: none; }

.simple-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.simple-list-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--n-900);
}

.simple-list-meta {
    font-size: 12px;
    color: var(--n-400);
    font-family: var(--mono);
}

.simple-list-body {
    color: var(--n-600);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    background: var(--n-50);
    padding: 12px;
    border-radius: var(--radius);
    margin-top: 8px;
}

.simple-list-preview {
    color: var(--n-500);
    font-size: 13px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ================================================================
   COLLAPSIBLE SECTION
   ================================================================ */
.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--n-200);
    margin-bottom: 10px;
}

.collapsible-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--n-700);
}

.collapsible-body {
    display: none;
}
.collapsible-body.open { display: block; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 16px; }
    .task-meta { display: none; }
    .toolbar { flex-wrap: wrap; }
    .detail-modal-body { grid-template-columns: 1fr; }
    .detail-left { border-right: none; border-bottom: 1px solid var(--n-200); }
}
