/* ============================================================
   Modal + Import + Format Guide
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg, rgba(5, 9, 18, 0.72));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: var(--z-modal);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: var(--s-10) var(--s-4);
  overflow-y: auto;
  animation: overlayIn 180ms ease;
}

.modal-overlay.open { display: flex; }

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: 100%;
  max-width: 880px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: modalIn 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--divider);
  background: var(--surface-2);
}

.modal-head h2 {
  font-size: 1.4rem;
  margin: 0;
}

.modal-head h2 .mono-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.22em;
  color: var(--primary);
  display: block;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.modal-close {
  color: var(--muted);
  padding: 6px;
  border-radius: var(--r-sm);
  transition: all 120ms ease;
  display: inline-flex;
}

.modal-close:hover {
  background: var(--offset);
  color: var(--text);
}

.modal-body {
  padding: var(--s-6);
  max-height: 72vh;
  overflow-y: auto;
}

.modal-foot {
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--divider);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
  background: var(--surface-2);
}

.modal-foot .left-actions {
  display: flex;
  gap: var(--s-2);
}

.modal-foot .right-actions {
  display: flex;
  gap: var(--s-2);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: var(--s-1);
  padding: 0 var(--s-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--divider);
}

.tab {
  padding: var(--s-3) var(--s-4);
  font-size: var(--text-sm);
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: all 120ms ease;
  font-weight: 500;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ---------- Drop zone ---------- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--r-md);
  padding: var(--s-10) var(--s-6);
  text-align: center;
  transition: all 150ms ease;
  cursor: pointer;
  background: var(--surface-2);
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--primary);
  background: var(--offset);
}

.dropzone .dropzone-icon {
  margin-bottom: var(--s-4);
  color: var(--muted);
}

.dropzone h3 {
  font-size: 1.3rem;
  margin-bottom: var(--s-2);
}

.dropzone p {
  color: var(--muted);
  font-size: var(--text-sm);
  margin-bottom: var(--s-4);
}

.dropzone .file-types {
  display: inline-flex;
  gap: var(--s-2);
}

/* ---------- Paste area ---------- */
.paste-area {
  width: 100%;
  min-height: 220px;
  padding: var(--s-4);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text);
  resize: vertical;
}

.paste-area:focus {
  outline: none;
  border-color: var(--primary);
}

.paste-area::placeholder {
  color: var(--faint);
}

/* ---------- Preview table (inside import) ---------- */
.preview-summary {
  display: flex;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}

.preview-stat {
  flex: 1;
  padding: var(--s-4);
  background: var(--surface-2);
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
  text-align: center;
}

.preview-stat.add { border-color: rgba(16, 185, 129, 0.4); }
.preview-stat.update { border-color: rgba(59, 130, 246, 0.4); }
.preview-stat.error { border-color: rgba(239, 68, 68, 0.4); }

.preview-stat .num {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  line-height: 1;
  margin-bottom: 4px;
}
.preview-stat.add .num { color: var(--success); }
.preview-stat.update .num { color: var(--info); }
.preview-stat.error .num { color: var(--danger); }
.preview-stat.ok .num { color: var(--primary); }

.preview-stat .label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.preview-list {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.preview-row {
  display: grid;
  grid-template-columns: 90px 1fr 140px;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  align-items: baseline;
  border-bottom: 1px solid var(--divider);
  font-size: var(--text-sm);
}

.preview-row:last-child { border-bottom: none; }

.preview-row .status {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.preview-row.add .status { color: var(--success); }
.preview-row.update .status { color: var(--info); }
.preview-row.error .status { color: var(--danger); }

.preview-row .name { color: var(--text); }
.preview-row .cat {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--faint);
  text-align: right;
}

.preview-row .err-detail {
  grid-column: 1 / -1;
  margin-top: var(--s-2);
  padding: var(--s-2) var(--s-3);
  background: var(--danger-soft);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--r-sm);
  color: #fca5a5;
  font-size: 0.78rem;
  line-height: 1.5;
}

/* ---------- Format guide ---------- */
.guide-section { margin-bottom: var(--s-8); }
.guide-section:last-child { margin-bottom: 0; }

.guide-section h3 {
  font-size: 1.25rem;
  margin-bottom: var(--s-3);
}

.guide-section p {
  color: var(--text);
  line-height: 1.7;
  margin-bottom: var(--s-3);
}

.guide-section p.muted { color: var(--muted); }

.field-table {
  width: 100%;
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: var(--s-4);
}

.field-table th,
.field-table td {
  text-align: left;
  padding: var(--s-3) var(--s-4);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--divider);
  vertical-align: top;
}

.field-table th {
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 500;
}

.field-table tr:last-child td { border-bottom: none; }

.field-table .field-name {
  font-family: var(--font-mono);
  color: var(--primary);
  width: 140px;
  font-size: 0.78rem;
}

.field-table .field-req {
  width: 80px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.field-table .field-req.required { color: var(--danger); }
.field-table .field-req.optional { color: var(--muted); }

.field-table .field-type {
  width: 100px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
}

pre.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text);
  margin-bottom: var(--s-4);
  white-space: pre;
}

pre.code-block .str { color: #a7e3c2; }
pre.code-block .key { color: #f5cb6b; }
pre.code-block .num { color: #b8b8f5; }
pre.code-block .com { color: var(--faint); font-style: italic; }

.download-row {
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
  margin-bottom: var(--s-5);
}

/* ---------- Toasts ---------- */
.toast-host {
  position: fixed;
  bottom: var(--s-5);
  right: var(--s-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-5);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 420px;
  animation: toastIn 260ms cubic-bezier(0.16, 1, 0.3, 1);
  font-size: var(--text-sm);
  pointer-events: auto;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }

@keyframes toastIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.toast .title {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}

.toast .body {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}
