/* ========================================
   飞书 ROI Agent — 简洁商务风
   ======================================== */

:root {
  --blue: #2563eb;
  --blue-light: #eff6ff;
  --blue-dark: #1e3a5f;
  --green: #059669;
  --red: #dc2626;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #1a1a1a;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
}

.app-container { max-width: 960px; margin: 0 auto; padding: 16px; }

/* Header */
.app-header {
  display: flex; align-items: baseline; gap: 12px;
  padding: 16px 0; border-bottom: 2px solid var(--blue);
  margin-bottom: 24px;
}
.app-header h1 { font-size: 22px; color: var(--blue-dark); }
.app-header .version { font-size: 12px; color: var(--gray-500); }

/* Sections */
.form-section {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.section-title {
  font-size: 16px; font-weight: 700; color: var(--blue-dark);
  border-left: 4px solid var(--blue); padding-left: 10px; margin-bottom: 16px;
}
.subsection-title {
  font-size: 13px; color: var(--gray-700); margin: 12px 0 8px;
  padding-bottom: 4px; border-bottom: 1px solid var(--gray-200);
}

/* Form */
.form-row { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.form-group { flex: 1; min-width: 140px; }
.form-group.flex-2 { flex: 2; min-width: 200px; }
.form-group label { display: block; font-size: 12px; color: var(--gray-700); margin-bottom: 4px; }
.form-group label .required { color: var(--red); }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--gray-300); border-radius: 6px;
  font-size: 13px; color: var(--gray-900);
  background: #fff; transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* Item cards */
.item-card {
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 12px; margin-bottom: 10px;
}
.item-card .form-row { margin-bottom: 8px; }
.item-card .item-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.item-card .item-label { font-size: 12px; color: var(--gray-500); }
.item-card .btn-remove {
  background: none; border: none; color: var(--red); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 2px 6px;
}
.item-card .btn-remove:hover { opacity: .7; }

/* Period grid (quarters/years) */
.period-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px; margin-top: 8px;
}
.period-cell {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: 6px; padding: 8px;
}
.period-cell .period-label { font-size: 11px; font-weight: 600; color: var(--gray-500); margin-bottom: 4px; }
.period-cell input { width: 100%; padding: 4px 6px; font-size: 12px; margin-bottom: 3px; }
.period-cell input[type="number"] { text-align: right; }

/* Buttons */
.btn-add {
  background: none; border: 1px dashed var(--gray-300); border-radius: var(--radius);
  color: var(--blue); cursor: pointer; font-size: 13px; padding: 8px 16px; width: 100%;
  transition: background .15s;
}
.btn-add:hover { background: var(--blue-light); }
.btn-add-sm { padding: 6px 12px; font-size: 12px; width: auto; }

.btn-submit, .btn-preview, .btn-secondary {
  padding: 10px 24px; border: none; border-radius: var(--radius);
  font-size: 14px; cursor: pointer; font-weight: 600;
  transition: opacity .15s, transform .1s;
}
.btn-submit:hover, .btn-preview:hover { opacity: .9; transform: translateY(-1px); }
.btn-submit { background: var(--blue); color: #fff; }
.btn-preview { background: var(--gray-100); color: var(--blue-dark); border: 1px solid var(--gray-300); }
.btn-secondary { background: #fff; color: var(--gray-700); border: 1px solid var(--gray-300); }

.action-bar {
  display: flex; gap: 12px; justify-content: flex-end;
  padding: 16px 0; position: sticky; bottom: 0;
  background: var(--gray-50); border-top: 1px solid var(--gray-200);
}

/* Preview Panel */
.preview-panel {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 16px; margin-top: 20px;
}
.preview-panel h3 { font-size: 14px; color: var(--blue-dark); margin-bottom: 12px; }

.kpi-row {
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
}
.kpi-badge {
  flex: 1; min-width: 100px;
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: 6px; padding: 8px 10px; text-align: center;
}
.kpi-badge .kpi-label { font-size: 10px; color: var(--gray-500); }
.kpi-badge .kpi-value { font-size: 16px; font-weight: 700; color: var(--blue-dark); }
.kpi-badge .kpi-value.green { color: var(--green); }
.kpi-badge .kpi-value.red { color: var(--red); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal {
  background: #fff; border-radius: 12px; width: 90%; max-width: 520px;
  box-shadow: 0 10px 40px rgba(0,0,0,.15);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
}
.modal-header h3 { font-size: 16px; color: var(--blue-dark); }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--gray-500); }
.modal-body { padding: 20px; font-size: 13px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--gray-200); display: flex; gap: 8px; justify-content: flex-end; }

/* Status */
.status-ok { color: var(--green); }
.status-err { color: var(--red); }

/* Loading */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--gray-300); border-top-color: var(--blue);
  border-radius: 50%; animation: spin .6s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 640px) {
  .app-container { padding: 8px; }
  .form-row { flex-direction: column; }
  .period-grid { grid-template-columns: repeat(2, 1fr); }
  .action-bar { flex-direction: column; }
}
