/* ========== Reset & Base ========== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --sidebar-width: 225px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #3b82f6;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --main-bg: #f1f5f9;
    --card-bg: #ffffff;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --transition: all 0.2s ease;
}

html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    background: var(--main-bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; }

/* ========== Sidebar (same as ips_new) ========== */
.sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-width); height: 100vh;
    background: var(--sidebar-bg);
    display: flex; flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo { display: flex; align-items: center; gap: 10px; }
.sidebar-logo svg { width: 28px; height: 28px; color: var(--sidebar-active); flex-shrink: 0; }
.sidebar-logo span { font-size: 15px; font-weight: 700; color: #f1f5f9; line-height: 1.3; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-section {
    font-size: 14px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: rgba(148,163,184,0.5);
    padding: 16px 12px 6px;
}

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 14px; font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
    white-space: nowrap;
}
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-text-active); }
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }

.sidebar-footer { padding: 16px 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm); margin-bottom: 8px; }
.sidebar-user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--sidebar-active);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 14px; font-weight: 600; flex-shrink: 0;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name { font-size: 14px; font-weight: 600; color: #e2e8f0; }
.sidebar-user-role { font-size: 14px; color: var(--text-muted); }
.nav-item.logout { color: #f87171; }
.nav-item.logout:hover { background: rgba(239,68,68,0.15); color: #fca5a5; }

/* ========== Main Content ========== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 32px;
}

.page-header { margin-bottom: 24px; }
.page-title { font-size: 24px; font-weight: 700; color: var(--text-primary); }
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }

/* ========== Unified Page Bar ========== */
.page-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 18px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 20px;
    min-height: 62px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.page-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.page-bar-title {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.page-bar-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 34px;
    padding: 0 14px;
    box-sizing: border-box;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #374151;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    background: #fff;
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}
.page-bar-back:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #1f2937;
}
.page-bar-back svg { width: 14px; height: 14px; flex-shrink: 0; }
.page-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
@media (max-width: 768px) {
    .page-bar { flex-wrap: nowrap; overflow-x: auto; }
    .page-bar-title { white-space: nowrap; }
}

.back-link {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 14px; color: var(--text-secondary);
    transition: var(--transition);
}
.back-link:hover { color: var(--primary); }
.back-link svg { width: 16px; height: 16px; }

/* ========== Cards ========== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 16px;
}

.card-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.card-body { padding: 24px; }

/* ========== Progress ========== */
.progress-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.progress-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.progress-card-header {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 12px;
}

.progress-subject-dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}

.progress-card-name {
    font-size: 14px; font-weight: 600; color: var(--text-primary);
}

.progress-bar-wrap {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease;
    min-width: 2px;
}

.progress-text {
    font-size: 14px; color: var(--text-muted);
}

.progress-detail-row {
    display: flex; align-items: center; margin-bottom: 12px;
}
.progress-detail-row:last-child { margin-bottom: 0; }
.progress-label { font-size: 14px; color: var(--text-secondary); white-space: nowrap; min-width: 80px; }
.progress-value { font-size: 14px; font-weight: 600; color: var(--text-primary); white-space: nowrap; min-width: 120px; text-align: right; }

/* ========== Content List ========== */
.content-list { display: flex; flex-direction: column; gap: 12px; }

.content-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    transition: var(--transition);
    border-left: 3px solid transparent;
    display: block;
}
.content-card:hover {
    box-shadow: var(--shadow-md);
    border-left-color: var(--primary);
}

.content-card-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.content-subject-tag {
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.content-card-name {
    font-size: 16px; font-weight: 600; color: var(--text-primary);
}

.content-done-badge {
    padding: 2px 8px;
    background: #d1fae5;
    color: #065f46;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
}

.content-card-body { margin-top: 4px; }

.content-node-types {
    display: flex; gap: 12px; margin-bottom: 8px; flex-wrap: wrap;
}

.node-type-tag {
    font-size: 14px;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
}

.content-progress-row {
    display: flex; align-items: center; gap: 12px;
}

.content-progress-text {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 100px;
}

/* ========== Task Cards ========== */
.task-list { display: flex; flex-direction: column; gap: 12px; }

.task-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 20px;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.task-card:hover { box-shadow: var(--shadow-md); border-left-color: var(--primary); }
.task-card.completed { border-left-color: var(--success); opacity: 0.75; }
.task-card.completed .task-content-name { opacity: 1; }
.task-card.draft { border-left-color: var(--text-muted); }

.task-card-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.task-subject-tag {
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.task-content-name {
    font-size: 14px; font-weight: 600; color: var(--text-primary);
    flex: 1;
}

.task-status-badges { display: flex; gap: 4px; }

.task-status-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}
.task-status-badge.done { background: #d1fae5; color: #065f46; }
.task-status-badge.pending { background: #fef3c7; color: #92400e; }
.task-status-badge.draft { background: #f1f5f9; color: var(--text-muted); }

/* ==========================================================
   任务项状态标识（全系统统一，实现见 views/partials/task_status.ejs）
   规范：统一图标 + 彩色文字，无背景框
     待发布   灰 + 圆圈     未完成   红 + 圆圈
     已完成   绿 + 对钩     部分完成 橙 + 对钩
     超额完成 紫 + 对钩
   ========================================================== */
.task-status-icon {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0;
    white-space: nowrap;
}
.task-status-icon svg { width: 18px; height: 18px; }
.task-status-icon.draft   { color: #64748b; }  /* 待发布：灰色 */
.task-status-icon.undone  { color: #ef4444; }  /* 未完成：红色 */
.task-status-icon.done    { color: #10b981; }  /* 已完成：绿色 */
.task-status-icon.partial { color: #f97316; }  /* 部分完成：橙色 */
.task-status-icon.over    { color: #8b5cf6; }  /* 超额完成：紫色 */
.task-status-icon.optional { color: #eab308; }  /* 自选内容：黄色 */

/* ==========================================================
   某日「总任务状态」标识（全系统统一，实现见 views/partials/card_status.ejs）
   规范：浅色背景框 + 彩色文字，无图标
     待生成   灰字 + 浅灰框     待发布   灰字 + 浅灰框
     已发布   蓝字 + 浅蓝框     已提交   绿字 + 浅绿框
     已过期   红字 + 浅红框
   ========================================================== */
.card-status-badge {
    display: inline-flex;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 6px;
    white-space: nowrap;
    line-height: 1.4;
}
.card-status-badge.generated { background: #f1f5f9; color: #64748b; } /* 待生成：灰 + 浅灰 */
.card-status-badge.draft     { background: #f1f5f9; color: #64748b; } /* 待发布：灰 + 浅灰 */
.card-status-badge.published { background: #dbeafe; color: #1e40af; } /* 已发布：蓝 + 浅蓝 */
.card-status-badge.completed { background: #d1fae5; color: #065f46; } /* 已提交：绿 + 浅绿 */
.card-status-badge.expired   { background: #fee2e2; color: #b91c1c; } /* 已过期：红 + 浅红 */

/* ==========================================================
   科目标识（全系统统一，实现见 views/partials/subject_badge.ejs）
   规范：浅色背景框 + 彩色文字，无图标
     语文   蓝字 + 浅蓝框
     数学   绿字 + 浅绿框
     英语   橙字 + 浅橙框
   ========================================================== */
.subject-badge {
    display: inline-flex;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}
.subject-badge.chinese { background: #dbeafe; color: #1e40af; } /* 语文：蓝 */
.subject-badge.math    { background: #d1fae5; color: #065f46; } /* 数学：绿 */
.subject-badge.english { background: #ffedd5; color: #c2410c; } /* 英语：橙 */
.subject-badge.unknown { background: #f1f5f9; color: #475569; } /* 兜底中性灰 */

.task-desc {
    font-size: 14px; color: var(--text-secondary);
    margin-bottom: 8px;
    padding-right: 1em;
}

.task-complete-btn-wrap { display: flex; justify-content: flex-end; }

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-family: inherit;
    line-height: 1;
    -webkit-appearance: none;
    appearance: none;
    min-height: 30px;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #e2e8f0; color: var(--text-secondary); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: var(--success-hover); }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 4px 10px; font-size: 14px; }

/* ========== Forms ========== */
.form-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px;
}

/* Field group for page/chapter sections */
.field-group {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
    background: #fafbfc;
}
.field-group-title {
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
}
.field-group .form-group:last-child {
    margin-bottom: 0;
}

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: white;
    transition: var(--transition);
    -webkit-appearance: none;
    appearance: none;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ========== Login ========== */
.login-body { background: #0f172a; display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { background: rgba(255, 255, 255, 0.5); border-radius: 16px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5); width: 100%; max-width: 400px; padding: 40px 36px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.login-logo { width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 50%; overflow: hidden; }
.login-logo-img { width: 100%; height: 100%; object-fit: cover; }
.login-title { text-align: center; font-size: 22px; font-weight: 800; color: #1e293b; margin-bottom: 2px; }
.login-title-sub { text-align: center; font-size: 14px; font-weight: 600; color: #1e293b; margin-bottom: 28px; }
.login-btn { width: 100%; padding: 12px; background: var(--primary); color: white; border: none; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600; cursor: pointer; transition: var(--transition); font-family: inherit; display: flex; align-items: center; justify-content: center; gap: 8px; -webkit-appearance: none; appearance: none; line-height: 1; }
.login-btn:hover { background: var(--primary-hover); }
.login-btn svg { width: 18px; height: 18px; }
.login-hint { text-align: center; margin-top: 20px; font-size: 14px; color: #334155; line-height: 1.8; }

/* ========== Alerts ========== */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #d1fae5; color: #065f46; }

/* ========== Badges ========== */
.badge { padding: 2px 8px; border-radius: 4px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-muted { background: #f1f5f9; color: var(--text-muted); }

/* ========== Empty State ========== */
.empty-state { text-align: center; padding: 60px 30px; color: var(--text-muted); }
.empty-state svg { width: 56px; height: 56px; margin-bottom: 16px; }
.empty-state p { font-size: 15px; margin-bottom: 8px; }

/* ========== Table ========== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 12px 24px; text-align: left; font-size: 14px; border-bottom: 1px solid var(--border); }
.data-table th { font-weight: 600; color: var(--text-secondary); background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }

/* ========== Detail Grid ========== */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

/* ========== Plan Info ========== */
.plan-info-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.plan-info-row:last-child { border-bottom: none; }
.plan-info-row span { font-size: 14px; color: var(--text-secondary); }
.plan-info-row strong { font-size: 14px; color: var(--text-primary); }

/* ========== Plan Form ========== */
.plan-list { display: flex; flex-direction: column; gap: 16px; }

.plan-card { margin-bottom: 0; }

.plan-card-title { display: flex; align-items: center; gap: 8px; }
.plan-card-title h3 { font-size: 16px; font-weight: 600; }

.plan-form-row {
    display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.plan-form-group { flex: 1; min-width: 120px; }
.plan-form-group label { font-size: 14px; color: var(--text-muted); margin-bottom: 4px; display: block; }
.plan-form-actions { display: flex; justify-content: flex-start; }

/* ========== Switch Toggle ========== */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #cbd5e1; transition: var(--transition); border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background: white; transition: var(--transition); border-radius: 50%; }
.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* ========== Admin Actions ========== */
.admin-actions {
    display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}

.admin-action-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    flex: 1; min-width: 280px;
}

.admin-action-card h4 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.admin-action-card p { font-size: 14px; color: var(--text-muted); margin-bottom: 12px; }

.admin-action-form { display: flex; gap: 8px; align-items: center; }

/* ========== Date Tabs ========== */
.date-tabs {
    display: flex; gap: 8px; margin-bottom: 20px; overflow-x: auto; padding-bottom: 4px;
}

.date-tab {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    box-shadow: var(--shadow);
    transition: var(--transition);
    white-space: nowrap;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    min-width: 100px;
}
.date-tab:hover { background: var(--primary); color: white; }
.date-tab.active { background: var(--primary); color: white; }

.date-tab-date { font-size: 14px; font-weight: 600; }
.date-tab-count { font-size: 14px; opacity: 0.8; }

/* ========== Task Detail ========== */
.task-detail-info { display: flex; flex-direction: column; gap: 12px; }
.task-detail-row { display: flex; gap: 12px; align-items: flex-start; }
.detail-label { font-size: 14px; color: var(--text-muted); min-width: 80px; }
.detail-value { font-size: 14px; color: var(--text-primary); font-weight: 500; }

/* ========== Mobile Hamburger ========== */
.mobile-toggle {
    display: none; position: fixed; top: 12px; left: 12px; z-index: 101;
    width: 40px; height: 40px;
    background: var(--sidebar-bg); border: none; border-radius: var(--radius-sm);
    cursor: pointer; align-items: center; justify-content: center;
}
.mobile-toggle svg { width: 22px; height: 22px; color: white; }

.mobile-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 99;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .mobile-toggle { display: flex; }
    .mobile-overlay.show { display: block; }
    .main-content { margin-left: 0; padding: 64px 16px 32px; }
    .progress-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .plan-form-row { flex-direction: column; gap: 8px; }
    .admin-actions { flex-direction: column; }
    .data-table { font-size: 14px; }
    .data-table th, .data-table td { padding: 8px 12px; }
}
/* ========== Page Header Row ========== */
.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

/* ========== Content Card (updated for actions) ========== */
.content-card {
    display: flex;
    flex-direction: column;
}

.content-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

/* ========== Content Card Actions ========== */
.content-card-actions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    margin-top: 12px;
}

/* ========== Card Header Actions ========== */
.card-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ========== Form Row (side-by-side) ========== */
.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
    min-width: 0;
}

/* ========== Required Field ========== */
.required {
    color: var(--danger);
    font-weight: 700;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .page-header-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

/* ========== Content Card - Right Side Actions (override) ========== */
.content-card {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch;
    gap: 0;
    padding: 0 !important;
}

.content-card-main {
    flex: 1;
    padding: 20px 24px;
    cursor: pointer;
    min-width: 0;
}

.content-card-main:hover {
    background: #f8fafc;
}

.content-card-sidebar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px 16px;
    border-left: 1px solid var(--border);
    align-items: stretch;
    justify-content: center;
    min-width: 100px;
    flex-shrink: 0;
}

.content-card-sidebar .btn {
    justify-content: flex-start;
    width: 100%;
}

/* Remove old content-card-actions and content-card-link styles */
.content-card-actions {
    display: none;
}

.content-card-link {
    display: none;
}

/* ========== Node Management Table ========== */
.node-table {
    width: 100%;
}

.node-table .view-cell {
    font-size: 14px;
    color: var(--text-primary);
}

.node-table .node-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    -webkit-appearance: none;
    appearance: none;
}

.node-table .node-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

/* Edit row form layout */
.node-table tr[id^="row-edit-"] form {
    display: contents;
}

.node-table tr[id^="row-edit-"] td:last-child {
    white-space: nowrap;
}

/* ========== Responsive - Content Card ========== */
@media (max-width: 768px) {
    .content-card {
        flex-direction: column !important;
    }

    .content-card-main {
        padding: 16px 20px;
    }

    .content-card-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        border-left: none;
        border-top: 1px solid var(--border);
        padding: 12px 20px;
    }

    .content-card-sidebar .btn {
        flex: 1;
        min-width: 70px;
    }

    .node-table {
        font-size: 14px;
    }

    .node-table th, .node-table td {
        padding: 8px 12px;
    }

    .form-row {
        flex-direction: column;
    }
}
/* ========== Content Table Layout ========== */
.content-table { width: 100%; border-collapse: collapse; }
.content-table th { font-weight: 600; color: var(--text-secondary); background: #f8fafc; font-size: 14px; white-space: nowrap; }
.content-table th, .content-table td { padding: 21px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.content-table tbody tr:last-child td { border-bottom: none; }
.content-table tbody tr:hover { background: #f8fafc; }

.subject-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.content-name-link {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
}
.content-name-link:hover {
    color: var(--primary-color, #6366f1);
    text-decoration: underline;
}

.done-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #10b98120;
    color: #10b981;
    font-size: 14px;
    font-weight: 600;
}

.cell-progress {
    display: flex;
    align-items: center;
    gap: 8px;
}
.mini-progress-bar {
    width: 80px;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    overflow: hidden;
    flex-shrink: 0;
}
.mini-progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}
.cell-progress-label {
    font-size: 14px;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 60px;
}
.all-progress {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.all-progress-numbers {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
}
.ap-num {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.ap-num strong {
    color: var(--text-primary);
    font-weight: 600;
}
.cell-progress-text {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.action-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.node-input {
    width: 100%;
    padding: 6px 10px;
    font-size: 14px;
}

/* Mobile */
@media (max-width: 768px) {
    .content-table { font-size: 14px; }
    .content-table th, .content-table td { padding: 10px 8px; }
    .mini-progress-bar { width: 50px; }
    .cell-progress-text { font-size: 14px; }
    .action-group { flex-wrap: wrap; }
}
/* ========== Hierarchical Node Management ========== */
.node-tree { display: flex; flex-direction: column; gap: 0; }

.node-l1-container {
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.node-l1-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8fafc;
    gap: 8px;
}
.node-l1-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}
.node-l1-no {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--primary-color, #6366f1);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}
.node-l1-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}
.node-l1-page {
    font-size: 14px;
    color: var(--text-secondary, #64748b);
    background: #e2e8f0;
    padding: 2px 10px;
    border-radius: 10px;
    white-space: nowrap;
}

.node-l2-list {
    padding: 4px 0 4px 44px;
    border-top: 1px solid var(--border, #e5e7eb);
    background: #fff;
}
.node-l2-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-bottom: 1px solid #f1f5f9;
    gap: 8px;
}
.node-l2-row:last-child { border-bottom: none; }
.node-l2-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.node-l2-no {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    background: #e2e8f0;
    color: var(--text-secondary, #64748b);
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}
.node-l2-name {
    font-size: 14px;
    color: var(--text-primary, #1e293b);
}
.node-l2-page {
    font-size: 14px;
    color: var(--text-secondary, #64748b);
    white-space: nowrap;
}
.node-l2-page::before { content: '·'; margin-right: 6px; color: #cbd5e1; }

.node-l2-empty {
    padding: 8px 16px;
    font-size: 14px;
    color: var(--text-muted, #94a3b8);
    font-style: italic;
}

/* Inline edit forms */
.inline-edit-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    flex-wrap: wrap;
}
.node-edit-input {
    padding: 6px 10px;
    font-size: 14px;
    max-width: 240px;
}
.node-edit-page {
    max-width: 120px;
}

/* Add node forms */
.node-l2-add-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-top: 1px dashed #e2e8f0;
    flex-wrap: wrap;
}
.node-add-input {
    padding: 6px 10px;
    font-size: 14px;
}
.node-add-page {
    max-width: 120px;
}

.node-l1-add-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border, #e5e7eb);
}
.node-l1-add-form .node-add-input {
    flex: 1;
    max-width: 400px;
}

.node-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Mobile */
@media (max-width: 768px) {
    .node-l1-header { flex-wrap: wrap; padding: 10px 12px; }
    .node-l1-info { flex-wrap: wrap; gap: 8px; }
    .node-l1-name { font-size: 14px; }
    .node-l2-list { padding-left: 28px; }
    .node-l2-row { flex-wrap: wrap; padding: 8px 12px; }
    .node-edit-input { max-width: 100%; }
    .node-l2-add-form { flex-direction: column; align-items: stretch; }
    .node-l2-add-form .node-add-input { max-width: 100%; }
    .node-l1-add-form { flex-direction: column; align-items: stretch; }
    .node-l1-add-form .node-add-input { max-width: 100%; }
}
/* alert-info style for add page hint */
.alert.alert-info {
    background: #e0f2fe;
    border: 1px solid #0284c7;
    color: #075985;
    padding: 12px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}
.alert.alert-info svg {
    flex-shrink: 0;
}

/* ========== Announcement Box (user-end) ========== */
.announcement-box {
    background: #fffde7;
    border: 1px solid #f0d85e;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    padding: 14px 18px;
    margin-top: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.announcement-icon {
    flex-shrink: 0;
    margin-top: 1px;
}
.announcement-icon svg {
    width: 20px;
    height: 20px;
    color: #d97706;
}
.announcement-content {
    flex: 1;
    min-width: 0;
}
.announcement-title {
    font-size: 14px;
    font-weight: 700;
    color: #92400e;
    margin-bottom: 4px;
}
.announcement-text {
    font-size: 14px;
    color: #78350f;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}
.switch-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

