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

:root {
  --primary: #0052CC;
  --primary-hover: #0747A6;
  --primary-light: rgba(0,82,204,0.08);
  --danger: #DE350B;
  --danger-light: #FFEBE6;
  --success: #006644;
  --success-bg: #00875A;
  --info: #0065FF;
  --info-bg: #4C9AFF;
  --warning: #FF8B00;
  --border: #DFE1E6;
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --text: #172B4D;
  --text-muted: #6B778C;
  --text-light: #97A0AF;
  --radius: 4px;
  --shadow-sm: 0 1px 2px rgba(9,30,66,0.08);
  --shadow-md: 0 4px 8px rgba(9,30,66,0.08), 0 0 1px rgba(9,30,66,0.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-toggle { display: flex; gap: 4px; }

.lang-toggle button {
  padding: 4px 12px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: all 0.15s;
}

.lang-toggle button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-header h2 { margin-bottom: 0; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  header { padding: 10px 12px; }
  header h1 { font-size: 16px; }
  .container { padding: 16px 10px; }
  .card { padding: 16px; }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input, .field textarea, .field select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
  font-family: inherit;
}

.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0,82,204,0.15);
}

.field textarea { resize: vertical; min-height: 60px; }

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-secondary:hover { background: var(--primary-light); }
.btn-success { background: var(--success-bg); color: #fff; }
.btn-success:hover { background: var(--success); }
.btn-info { background: var(--info-bg); color: #fff; }
.btn-info:hover { background: var(--info); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #BF2600; }
.btn-ghost {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  border-radius: var(--radius);
  transition: color 0.15s;
}
.btn-ghost:hover { color: var(--danger); }

/* Template Grid */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.template-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.template-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.template-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.template-icon { font-size: 28px; }
.template-name { font-size: 13px; font-weight: 600; color: var(--text); }

/* Plan Item */
.plan-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  background: var(--bg);
  position: relative;
}

.plan-item .plan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.plan-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.plan-badge.recommended {
  background: var(--primary);
  color: #fff;
}

/* Service Row */
.service-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--surface);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.service-row .field { flex: 1; min-width: 120px; }
.service-row .field.service-name-field { flex: 2; min-width: 200px; }
.service-row .field.service-desc-field { flex: 3; min-width: 200px; }

.service-row .plan-prices {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.service-row .plan-prices .field { min-width: 100px; flex: unset; width: 120px; }

.service-row .service-actions {
  display: flex;
  align-items: center;
  padding-top: 20px;
}

@media (max-width: 640px) {
  .service-row { flex-direction: column; }
  .service-row .field { min-width: 100%; }
  .service-row .plan-prices .field { width: 100%; }
}

/* Option Row */
.option-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--surface);
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.option-row .field { flex: 1; min-width: 120px; }
.option-row .field:first-child { flex: 2; min-width: 200px; }

/* Discount Row */
.discount-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--surface);
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.discount-row .field { flex: 1; min-width: 120px; }
.discount-row .field:first-child { flex: 2; min-width: 200px; }

/* Version list */
.version-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  background: var(--bg);
}

.version-item .version-info { flex: 1; }
.version-item .version-name { font-weight: 600; font-size: 14px; }
.version-item .version-date { font-size: 12px; color: var(--text-muted); }
.version-item .version-actions { display: flex; gap: 6px; }

/* Actions Bar */
.actions-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 16px 0;
}

/* Advice Card */
.advice-card {
  background: #FFFAE6;
  border-color: #FFE380;
}

.advice-card h2 { color: #172B4D; }
.advice-content p { margin-bottom: 8px; font-size: 14px; line-height: 1.6; }
.advice-tip { padding: 8px 12px; background: rgba(255,255,255,0.6); border-radius: var(--radius); margin-bottom: 8px; font-size: 14px; }

/* Related Tools Grid */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.related-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s;
}

.related-link:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.related-icon { font-size: 28px; }
.related-link strong { display: block; font-size: 14px; color: var(--primary); }
.related-link small { font-size: 12px; color: var(--text-muted); }

/* FAQ */
.faq-section { background: var(--surface); }

.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

.faq-item:last-child { border-bottom: none; }

.faq-item summary {
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 0;
  color: var(--text);
  list-style: none;
}

.faq-item summary::before {
  content: '▶ ';
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
  display: inline-block;
  margin-right: 6px;
}

.faq-item[open] summary::before {
  transform: rotate(90deg);
}

.faq-item p {
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.7;
  padding-left: 18px;
}

/* Preview */
.preview-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  overflow-y: auto;
}

.preview-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 8px;
}

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

.preview-content {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px;
  box-shadow: var(--shadow-md);
}

@media (max-width: 640px) {
  .preview-content { padding: 24px 16px; }
}

.preview-content .pv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.preview-content .pv-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
}

.preview-content .pv-biz-name {
  font-size: 16px;
  color: var(--text-muted);
  margin-top: 4px;
}

.preview-content .pv-meta {
  text-align: right;
  font-size: 13px;
  color: var(--text-muted);
}

/* Plan comparison table */
.pv-plan-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 14px;
}

.pv-plan-table th {
  background: var(--bg);
  padding: 12px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

.pv-plan-table th.recommended {
  background: var(--primary);
  color: #fff;
}

.pv-plan-table th:first-child {
  text-align: left;
  width: 35%;
}

.pv-plan-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
}

.pv-plan-table td:first-child { text-align: left; font-weight: 500; }
.pv-plan-table td.recommended-col { background: rgba(0,82,204,0.03); }

.pv-plan-table .service-desc-cell {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.pv-plan-table .price-cell { font-variant-numeric: tabular-nums; }

/* Options table in preview */
.pv-options-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 14px;
}

.pv-options-table th {
  background: var(--bg);
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

.pv-options-table th:last-child { text-align: right; }
.pv-options-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.pv-options-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* Discount section in preview */
.pv-discount-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.pv-discount-item:last-child { border-bottom: none; }

.pv-section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 24px 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--primary);
}

.pv-notes {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  white-space: pre-line;
}

.pv-tax-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 16px;
  text-align: right;
}

/* Saved indicator */
.save-indicator {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--success-bg);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 300;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  pointer-events: none;
}

.save-indicator.show {
  opacity: 1;
  transform: translateY(0);
}

/* Unit select inline */
.unit-select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}

/* Checkbox as toggle */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* Print styles */
@media print {
  body * { visibility: hidden; }
  .preview-content, .preview-content * { visibility: visible; }
  .preview-content {
    position: fixed;
    inset: 0;
    border: none !important;
    box-shadow: none !important;
    padding: 20px !important;
  }
  .no-print { display: none !important; }
  header, footer, .preview-toolbar { display: none !important; }
}
