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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #ffffff;
  color: #1e40af;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 32px;
  background: #2563eb;
  border-bottom: 1px solid #1d4ed8;
}
header .logo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  flex-shrink: 0;
  display: block;
}
header h1 { font-size: 1.25rem; font-weight: 700; color: #ffffff; }
header span { font-size: 0.8rem; color: #bfdbfe; margin-left: 2px; }

/* ── Main layout ── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 48px;
  gap: 20px;
}

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.toolbar-left { display: flex; align-items: center; gap: 10px; }
.file-badge {
  font-size: 0.75rem;
  color: #1e40af;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 4px 10px;
  font-family: monospace;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}
.status-dot.saving { background: #f59e0b; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 4px;
}
.tab-btn {
  padding: 7px 18px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  background: transparent;
  color: #1e40af;
  transition: all .15s;
}
.tab-btn.active {
  background: #2563eb;
  color: #ffffff;
}
.tab-btn:hover:not(.active) { color: #1d4ed8; background: #dbeafe; }

/* ── Action buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 18px;
  border: none; border-radius: 8px;
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.btn-primary {
  background: #2563eb; color: #ffffff;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { background: #bfdbfe; color: #93c5fd; cursor: not-allowed; }

.btn-outline {
  background: transparent;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}
.btn-outline:hover { border-color: #2563eb; color: #1d4ed8; }

.btn-danger {
  background: transparent;
  border: 1px solid #fca5a5;
  color: #dc2626;
}
.btn-danger:hover { background: #fee2e222; }

/* ── Panels ── */
.panel { display: none; flex-direction: column; gap: 16px; }
.panel.active { display: flex; }

/* ── Editor ── */
.editor-wrap {
  position: relative;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
}
.editor-wrap textarea {
  width: 100%;
  min-height: 520px;
  padding: 20px 22px;
  background: transparent;
  border: none;
  outline: none;
  color: #1e3a8a;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.82rem;
  line-height: 1.7;
  resize: vertical;
  tab-size: 2;
}
.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #eff6ff;
  border-top: 1px solid #bfdbfe;
}
.char-count { font-size: 0.75rem; color: #3b82f6; }

/* ── Preview ── */
.preview-wrap {
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #ffffff;
  padding: 28px 32px;
  min-height: 520px;
}
.preview-wrap h1 { font-size: 1.5rem; color: #1e3a8a; margin-bottom: 12px; border-bottom: 1px solid #bfdbfe; padding-bottom: 10px; }
.preview-wrap h2 { font-size: 1.15rem; color: #1d4ed8; margin: 22px 0 8px; }
.preview-wrap h3 { font-size: 1rem; color: #2563eb; margin: 16px 0 6px; }
.preview-wrap p  { color: #1e40af; line-height: 1.75; margin-bottom: 8px; }
.preview-wrap ul, .preview-wrap ol { padding-left: 22px; margin-bottom: 10px; }
.preview-wrap li { color: #1e40af; line-height: 1.7; }
.preview-wrap code { background: #eff6ff; color: #1d4ed8; padding: 2px 6px; border-radius: 4px; font-size: 0.8rem; }
.preview-wrap pre { background: #eff6ff; padding: 14px 18px; border-radius: 8px; overflow-x: auto; margin-bottom: 12px; }
.preview-wrap pre code { background: none; padding: 0; }
.preview-wrap hr { border: none; border-top: 1px solid #bfdbfe; margin: 20px 0; }
.preview-wrap strong { color: #1e3a8a; }

/* ── Upload panel ── */
.upload-zone {
  border: 2px dashed #bfdbfe;
  border-radius: 12px;
  padding: 60px 32px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: #ffffff;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: #2563eb;
  background: #eff6ff;
}
.upload-icon { font-size: 3rem; margin-bottom: 12px; }
.upload-zone h3 { color: #1e3a8a; margin-bottom: 8px; }
.upload-zone p  { color: #3b82f6; font-size: 0.85rem; }
.upload-zone input[type="file"] { display: none; }

.upload-preview {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 18px 22px;
  display: none;
  gap: 14px;
  align-items: center;
}
.upload-preview.visible { display: flex; }
.upload-preview .file-icon { font-size: 2rem; }
.upload-preview .file-info { flex: 1; }
.upload-preview .file-name { font-weight: 600; color: #1e3a8a; font-size: 0.9rem; }
.upload-preview .file-size { color: #3b82f6; font-size: 0.78rem; margin-top: 2px; }

/* ── Contacts panel ── */
.contacts-card {
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 2px 12px rgba(37,99,235,.06);
  overflow: hidden;
}

.contacts-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 24px;
  background: linear-gradient(135deg, #eff6ff 0%, #f8faff 100%);
  border-bottom: 1px solid #dbeafe;
}

.contacts-card-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: #2563eb;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.contacts-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e3a8a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.contacts-card-sub {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 2px;
}

.contacts-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2563eb;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 20px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
}

/* Form grid */
.contacts-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 22px 24px 0;
}

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

.cf-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #3b5ba5;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.cf-required { color: #ef4444; font-size: 0.8rem; }

.contacts-input {
  padding: 10px 14px;
  border: 1.5px solid #dbeafe;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #1e3a8a;
  background: #f8faff;
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.contacts-input:focus {
  border-color: #2563eb;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.contacts-input::placeholder { color: #93c5fd; }

.contacts-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px 22px;
  margin-top: 16px;
}

.cf-hint {
  font-size: 0.73rem;
  color: #94a3b8;
}

/* Contact rows */
.contacts-list {
  display: flex;
  flex-direction: column;
}

.contact-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  border-bottom: 1px solid #f1f5f9;
  transition: background .12s;
}
.contact-row:last-child { border-bottom: none; }
.contact-row:hover { background: #f8faff; }

.contact-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: .04em;
}

.contact-info { flex: 1; min-width: 0; }

.contact-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1e3a8a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.contact-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: #64748b;
}

.contact-meta svg { opacity: .6; flex-shrink: 0; }

.contact-delete {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid #fca5a5;
  background: transparent;
  color: #dc2626;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s;
  flex-shrink: 0;
}
.contact-row:hover .contact-delete { opacity: 1; }
.contact-delete:hover { background: #fee2e2; }

.contacts-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 24px;
  color: #94a3b8;
  font-size: 0.85rem;
}

.contacts-loading {
  padding: 32px 24px;
  text-align: center;
  color: #93c5fd;
  font-size: 0.85rem;
  font-style: italic;
}

@media (max-width: 600px) {
  .contacts-form-grid { grid-template-columns: 1fr; }
}

/* ── Recordings ── */
.recording-row { align-items: center; }

.rec-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  display: flex; align-items: center; justify-content: center;
  color: #2563eb;
  flex-shrink: 0;
}

.rec-play-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 28px; right: 28px;
  background: #ffffff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 12px 20px;
  display: flex; align-items: center; gap: 10px;
  font-size: 0.85rem;
  color: #1e40af;
  box-shadow: 0 8px 24px rgba(37,99,235,.15);
  transform: translateY(80px);
  opacity: 0;
  transition: all .3s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
  z-index: 9999;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: #22c55e88; }
.toast.error   { border-color: #ef444488; }
.toast-icon { font-size: 1.1rem; }

/* ── Service type selector ── */
.service-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.service-type-card {
  border: 1.5px solid #dbeafe;
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: border-color .15s, box-shadow .15s, background .15s;
  background: #f8faff;
}
.service-type-card:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}
.service-type-card.active {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.stc-icon {
  width: 38px; height: 38px;
  border-radius: 9px;
  background: #fff;
  border: 1px solid #dbeafe;
  display: flex; align-items: center; justify-content: center;
  color: #2563eb;
  flex-shrink: 0;
}
.stc-icon.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.stc-body { flex: 1; min-width: 0; }

.stc-title {
  font-size: .88rem;
  font-weight: 700;
  color: #1e3a8a;
  margin-bottom: 3px;
}

.stc-desc {
  font-size: .73rem;
  color: #64748b;
  margin-bottom: 9px;
  line-height: 1.4;
}

.stc-tools { display: flex; flex-wrap: wrap; gap: 4px; }

.tool-chip {
  font-size: .67rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  background: #dbeafe;
  color: #1d4ed8;
  font-family: 'Fira Code', monospace;
}

.stc-check {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── Mission editor ── */
.mission-editor {
  width: 100%;
  min-height: 360px;
  padding: 16px;
  border: 1.5px solid #dbeafe;
  border-radius: 8px;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: .78rem;
  color: #1e3a8a;
  background: #f8faff;
  outline: none;
  resize: vertical;
  line-height: 1.6;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.mission-editor:not([readonly]):focus {
  border-color: #2563eb;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.mission-editor[readonly] {
  color: #64748b;
  cursor: default;
}

@media (max-width: 640px) {
  .service-type-grid { grid-template-columns: 1fr; }
}
