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

html { font-size: 16px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

/* ========== 头部 ========== */
.app-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: #fff;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.header-inner {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}
.app-header h1 { font-size: 20px; font-weight: 600; }
.back-home {
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    opacity: 0.9;
    transition: opacity 0.2s;
}
.back-home:hover { opacity: 1; text-decoration: underline; }

.watermark {
    background: #fff3cd;
    color: #856404;
    text-align: center;
    padding: 8px 16px;
    font-size: 12px;
    border-bottom: 1px solid #ffeeba;
}

/* ========== 主体布局 ========== */
.main-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

@media (max-width: 640px) {
    .main-content { padding: 12px; }
}

/* ========== 面板通用 ========== */
.form-panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    padding: 24px;
}
.form-panel h2 {
    font-size: 18px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e5e7eb;
    color: #1e3a8a;
}

/* ========== 表单样式 ========== */
.form-group { margin-bottom: 20px; }
.form-group > label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #374151;
}
.required { color: #dc2626; margin-right: 2px; }

input[type="text"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="time"],
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}
input:focus, select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.radio-group, .checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.radio-item, .checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    transition: background 0.2s;
}
.radio-item:hover, .checkbox-item:hover { background: #f3f4f6; }
.radio-item input, .checkbox-item input { cursor: pointer; }

.hint-inline {
    color: #6b7280;
    font-size: 12px;
    margin-left: 4px;
}

.alert-box {
    margin-top: 12px;
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
    font-size: 13px;
    line-height: 1.7;
}

.date-row, .date-range-row, .contact-row, .leader-row {
    display: flex;
    gap: 10px;
}
.date-row input[type="date"] { flex: 1; min-width: 140px; }
.date-row input[type="text"] { flex: 1; min-width: 120px; }

.date-range-row { flex-direction: column; gap: 8px; }
.date-block {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f9fafb;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: background 0.2s;
}
.date-block:hover { background: #f3f4f6; }
.date-block:active { background: #e5e7eb; }
.date-label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    pointer-events: none;
}
.date-block input[type="date"] { flex: 1; min-width: 130px; }
.date-block .time-select { flex: 1; min-width: 60px; }
.time-colon { color: #6b7280; font-size: 13px; flex-shrink: 0; }

.contact-row input { flex: 1; min-width: 80px; }
.leader-row input { flex: 1; min-width: 100px; }

/* ========== 专家列表 ========== */
.expert-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.expert-num {
    width: 24px;
    text-align: center;
    font-size: 13px;
    color: #6b7280;
    flex-shrink: 0;
}
.expert-row input {
    flex: 1;
    min-width: 80px;
}
.btn-icon {
    width: 28px;
    height: 28px;
    border: none;
    background: #fee2e2;
    color: #dc2626;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.btn-icon:hover { background: #fecaca; }
.btn-add {
    margin-top: 6px;
    padding: 8px 16px;
    border: 1px dashed #3b82f6;
    background: #eff6ff;
    color: #1d4ed8;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.btn-add:hover { background: #dbeafe; }

/* ========== 预算区域 ========== */
.budget-income {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f9fafb;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}
.budget-income span {
    font-size: 14px;
    color: #374151;
    font-weight: 500;
    white-space: nowrap;
}
.budget-income input {
    flex: 1;
    min-width: 100px;
}

.tag-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}
.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #d1d5db;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.tag-item:hover { background: #f3f4f6; }
.tag-item input { display: none; }
.tag-item span { color: #374151; }
.tag-item.active {
    background: #dbeafe;
    border-color: #3b82f6;
    color: #1d4ed8;
}
.tag-item.active span {
    color: #1d4ed8;
    font-weight: 500;
}

/* ========== 议程区域 ========== */
.agenda-section { margin-top: 28px; padding-top: 20px; border-top: 2px solid #e5e7eb; }
.agenda-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 12px;
    position: relative;
}
.agenda-index {
    position: absolute;
    top: -10px;
    left: 10px;
    background: #1e3a8a;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 10px;
}
.agenda-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding-top: 6px;
}
@media (max-width: 640px) {
    .agenda-grid { grid-template-columns: 1fr; }
}
.agenda-col > label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 6px;
}
.agenda-col input {
    width: 100%;
}
.agenda-col-wide { grid-column: 1 / -1; }
@media (min-width: 641px) {
    .agenda-col-wide { grid-column: auto; }
}

.time-range {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 4px 8px;
}
.time-range .time-select {
    flex: 1;
    min-width: 55px;
    padding: 6px 4px;
    border: none;
    background: transparent;
    font-size: 14px;
}
.time-range .time-select:focus {
    outline: none;
    box-shadow: none;
}
.time-sep {
    color: #9ca3af;
    font-size: 13px;
    flex-shrink: 0;
}

.person-list { display: flex; flex-direction: column; gap: 6px; }
.person-line {
    display: flex;
    gap: 8px;
}
.person-line input { flex: 1; min-width: 70px; }

.btn-add-sm {
    margin-top: 6px;
    padding: 4px 10px;
    border: 1px dashed #3b82f6;
    background: #eff6ff;
    color: #1d4ed8;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}
.btn-add-sm:hover { background: #dbeafe; }

.btn-remove-agenda {
    margin-top: 10px;
    padding: 6px 12px;
    border: none;
    background: #fee2e2;
    color: #dc2626;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}
.btn-remove-agenda:hover { background: #fecaca; }

.agenda-hint { font-weight: normal; color: #9ca3af; font-size: 11px; }

/* ========== 生成按钮 ========== */
.btn-generate {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    margin-top: 10px;
}
.btn-generate:hover {
    box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}
.btn-generate:active { transform: scale(0.99); }

/* ========== 隐藏 PDF 源容器 ========== */
#pdf-source {
    position: fixed;
    top: 0;
    left: -9999px;
    width: 210mm;
    z-index: -1;
}

/* A4 纸张 */
.paper {
    width: 210mm;
    min-height: 297mm;
    background: #fff;
    padding: 18mm;
    font-family: "SimSun", "Songti SC", "Noto Serif CJK SC", serif;
    font-size: 13px;
    color: #000;
    line-height: 1.6;
    box-sizing: border-box;
    margin-bottom: 20px;
}

.paper-title {
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 16px;
    letter-spacing: 2px;
}

.form-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.form-table td, .form-table th {
    border: 1px solid #000;
    padding: 5px 8px;
    vertical-align: top;
    word-break: break-all;
}
.label-cell {
    background: #f3f4f6;
    font-weight: bold;
    text-align: center;
}
.value-cell {
    text-align: left;
}
.sign-row .value-cell {
    height: 72px;
}

.paper-notice {
    margin-top: 12px;
    padding: 8px 12px;
    border: 1px solid #000;
}
.notice-title {
    font-weight: bold;
    text-align: center;
    margin-bottom: 4px;
    font-size: 13px;
}
.paper-notice ol {
    padding-left: 16px;
    margin: 0;
}
.paper-notice li {
    margin-bottom: 2px;
    font-size: 12px;
}

/* 承诺书专用 */
.paper-promise {
    padding: 25mm;
    font-size: 15px;
    line-height: 2.0;
}
.paper-promise .paper-title {
    font-size: 24px;
}
.promise-body {
    font-size: 15px;
    line-height: 2.0;
}
.promise-body > p {
    margin-bottom: 14px;
    text-indent: 2em;
}
.promise-body ol {
    padding-left: 2em;
    margin-bottom: 30px;
}
.promise-body li {
    margin-bottom: 10px;
}
.promise-sign-block {
    margin-top: 40px;
}
.promise-sign-line {
    margin-bottom: 36px;
}
.promise-sign-line p {
    margin-bottom: 10px;
}
.promise-footer {
    margin-top: 40px;
    text-align: center;
    font-size: 13px;
    color: #333;
}

/* 议程 PDF 表格 */
.agenda-pdf-table th {
    background: #f3f4f6;
    font-weight: bold;
    text-align: center;
    font-size: 12px;
}
.agenda-pdf-table td {
    font-size: 12px;
    padding: 4px 6px;
}


/* ========== 移动端适配 ========== */
@media (max-width: 640px) {
    .header-inner { height: 52px; }
    .app-header h1 { font-size: 16px; }
    .back-home { font-size: 12px; }
    .form-panel { padding: 16px; }
    .date-row, .contact-row, .leader-row { flex-direction: column; gap: 8px; }
    .radio-group, .checkbox-group { flex-direction: column; gap: 8px; }
    .date-block { flex-wrap: wrap; }
    .date-block input[type="date"] { min-width: 110px; }
    .date-block .time-select { min-width: 50px; }
    .time-range { gap: 4px; padding: 4px 6px; }
    .time-range .time-select { min-width: 45px; padding: 6px 2px; font-size: 13px; }
    .time-colon { font-size: 12px; }
    .time-sep { font-size: 12px; }
    .paper { transform: scale(1); padding: 12px; }
    .paper-title { font-size: 18px; }
    .label-cell { font-size: 12px; }
    .value-cell { font-size: 12px; }
}
