/* Reset & Base */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5; color: #333; line-height: 1.6;
}

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 20px; }

/* Header */
header {
  background: #1a2332; color: #fff; padding: 24px 30px;
  border-radius: 8px 8px 0 0;
}
header h1 { font-size: 24px; }
header .subtitle { font-size: 13px; opacity: .8; margin-top: 4px; }
.header-row {
  display: flex; justify-content: space-between; align-items: flex-start;
}
.btn-lang {
  color: #fff; border: 1px solid rgba(255,255,255,.3); background: transparent;
  font-size: 12px; padding: 4px 14px; border-radius: 4px; cursor: pointer;
  transition: all .2s;
}
.btn-lang:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.5); }

/* Toolbar */
.toolbar {
  background: #fff; padding: 12px 20px; border-bottom: 1px solid #e0e0e0;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.toolbar-sep { width: 1px; height: 24px; background: #ddd; margin: 0 4px; }

/* Buttons */
.btn {
  padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer;
  font-size: 13px; font-weight: 500; transition: all .2s;
  display: inline-flex; align-items: center; gap: 4px;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-outline { background: #fff; color: #374151; border: 1px solid #d1d5db; }
.btn-outline:hover { background: #f3f4f6; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Card sections */
.card { background: #fff; margin-top: 1px; }
.card.last { border-radius: 0 0 8px 8px; }
.card-header {
  padding: 16px 20px; display: flex; justify-content: space-between;
  align-items: center; border-bottom: 1px solid #e5e7eb;
}
.card-header.toggleable { cursor: pointer; user-select: none; }
.card-header h2 {
  font-size: 16px; color: #1f2937;
  display: flex; align-items: center; gap: 8px;
}
.card-header .caret {
  font-size: 12px; color: #9ca3af; transition: transform .2s;
}
.card-header .caret.up { transform: rotate(180deg); }
.card-body { padding: 20px; }
.card-body.collapsed { display: none; }

/* Form grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; }
.field label {
  font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 4px;
}
.field .req { color: #ef4444; }
.field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px;
  font-size: 13px; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.field small { font-size: 11px; color: #9ca3af; margin-top: 2px; }
.field input.error, .field select.error { border-color: #ef4444; }

/* Decision block */
.decision {
  background: #f0f7ff; padding: 16px; border-radius: 8px;
  border-left: 3px solid #2563eb; margin-bottom: 16px;
}
.decision h4 { font-size: 13px; color: #1e40af; margin-bottom: 12px; }
.radio-row { display: flex; gap: 20px; margin-bottom: 8px; }
.radio-row label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; cursor: pointer; font-weight: normal;
}

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  background: #f9fafb; padding: 10px 12px; text-align: left;
  font-weight: 600; color: #6b7280; border-bottom: 2px solid #e5e7eb;
  font-size: 12px;
}
.table td { padding: 10px 12px; border-bottom: 1px solid #f3f4f6; }
.table tr:hover td { background: #f9fafb; }
.table .actions { display: flex; gap: 6px; }
.table .actions button {
  padding: 4px 8px; font-size: 11px; border-radius: 4px;
  cursor: pointer; border: 1px solid #d1d5db; background: #fff; color: #374151;
}
.table .actions button:hover { background: #f3f4f6; }
.table .actions .btn-del { color: #ef4444; border-color: #fca5a5; }
.table .actions .btn-del:hover { background: #fef2f2; }

/* Summary */
.summary {
  padding: 12px 0; margin-top: 8px; border-top: 2px solid #e5e7eb;
  font-size: 13px; color: #6b7280; display: flex; gap: 20px;
}

/* Badge */
.badge {
  background: #2563eb; color: #fff; font-size: 11px;
  padding: 2px 8px; border-radius: 10px; font-weight: 600;
}

/* Empty state */
.empty { text-align: center; padding: 40px 20px; color: #9ca3af; font-size: 14px; }

/* Export */
.export-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.preview {
  background: #1e293b; color: #e2e8f0; padding: 16px; border-radius: 6px;
  font-size: 12px; line-height: 1.5; max-height: 400px; overflow: auto;
  white-space: pre-wrap; word-wrap: break-word;
}

/* Modal */
.modal { display: none; position: fixed; inset: 0; z-index: 1000; }
.modal.open {
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 40px;
}
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); }
.modal-dialog {
  position: relative; background: #fff; border-radius: 12px;
  width: 720px; max-width: 95vw; max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-head {
  padding: 16px 20px; display: flex; justify-content: space-between;
  align-items: center; border-bottom: 1px solid #e5e7eb;
}
.modal-head h3 { font-size: 16px; }
.modal-x {
  background: none; border: none; font-size: 24px;
  cursor: pointer; color: #9ca3af; padding: 0 4px;
}
.modal-x:hover { color: #374151; }
.modal-tabs {
  display: flex; border-bottom: 1px solid #e5e7eb; padding: 0 20px;
}
.tab {
  padding: 10px 16px; background: none; border: none; font-size: 13px;
  cursor: pointer; color: #6b7280;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 500; }
.tab:hover { color: #374151; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.modal-foot {
  padding: 16px 20px; border-top: 1px solid #e5e7eb;
  display: flex; justify-content: flex-end; align-items: center; gap: 8px;
}
.modal-error { color: #ef4444; font-size: 12px; margin-right: auto; }

/* Conditional field groups */
.cond-group { display: none; }
.cond-group.show { display: block; }

/* FX sub-section */
.fx-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid #e5e7eb; }
.fx-section h4 { font-size: 13px; color: #6b7280; margin-bottom: 12px; }
.section-label {
  font-size: 14px; color: #374151; margin: 16px 0 12px; font-weight: 500;
}

/* Alert */
.alert {
  padding: 12px 16px; border-radius: 6px; font-size: 13px; margin-bottom: 12px;
}
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fef2f2; color: #991b1b; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* Responsive */
@media (max-width: 768px) {
  .container { padding: 10px; }
  .grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .toolbar { padding: 10px; }
  .modal-dialog { width: 100%; max-width: 100%; border-radius: 8px; }
  .modal.open { padding-top: 20px; }
  .radio-row { flex-direction: column; gap: 8px; }
}
