@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap");

:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #1BAC5DFF;
  --brand-hover: #1BAC5DFF;
  --brand-soft: rgba(27, 172, 93, 0.08);
  --brand-soft-2: rgba(27, 172, 93, 0.15);
  --border: #e2e8f0;
  --radius: 16px;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1000px;
  margin: 40px auto;
  padding: 0 24px;
}

/* Header */
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 32px;
}

.title {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1;
}

.subtitle {
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 6px;
}

/* Audience Tabs */
.audience-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  background: var(--card);
  padding: 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.audience-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 20px;
  border: none;
  background: transparent;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  transition: all 0.2s;
}

.audience-tab:hover {
  background: var(--bg);
}

.audience-tab.is-active {
  background: var(--brand);
  color: white;
}

.audience-tab .tab-icon {
  font-size: 24px;
}

.audience-tab .tab-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.audience-tab.is-active .tab-label {
  color: white;
}

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 20px;
}

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

.panel-header h2 {
  margin: 0;
}

/* Algorithms List */
.algorithms-list {
  display: grid;
  gap: 12px;
}

.algorithm-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.2s;
}

.algorithm-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow);
}

.algorithm-card.is-default {
  border-color: var(--brand);
  background: var(--brand-soft);
}

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

.algo-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.algo-name .default-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  background: var(--brand);
  color: white;
  border-radius: 4px;
  text-transform: uppercase;
}

.algo-meta {
  font-size: 12px;
  color: var(--muted);
}

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

.algo-btn {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: white;
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.algo-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.algo-btn.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

/* Form Elements */
h2 {
  margin: 0 0 20px;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.stack {
  display: grid;
  gap: 20px;
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  outline: none;
}

.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft-2);
}

.textarea {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
}

.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

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

.hint {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  background: #f1f5f9;
  padding: 12px 16px;
  border-radius: 12px;
}

.hint code {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  background: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}

.dropzone-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.dropzone-sub {
  font-size: 13px;
  font-weight: 500;
}

.dropzone-file {
  margin-top: 16px;
  display: inline-flex;
  padding: 8px 16px;
  background: var(--brand);
  color: white;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

/* Preview */
.preview-area {
  padding: 16px;
  font-size: 11px;
  overflow-x: auto;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.preview-title {
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--brand);
}

.preview-area table {
  width: 100%;
  border-collapse: collapse;
}

.preview-area th,
.preview-area td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.preview-area th {
  background: var(--brand);
  color: white;
  font-weight: 700;
}

/* Buttons */
.btn {
  padding: 14px 24px;
  border-radius: 12px;
  border: none;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover {
  background: var(--brand-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(27, 172, 93, 0.25);
}

.btn-secondary {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: #f8fafc;
  color: var(--brand);
  border-color: var(--brand);
  box-shadow: none;
}

.btn-small {
  padding: 10px 16px;
  font-size: 13px;
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

/* Messages */
.msg {
  font-size: 13px;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 10px;
  display: none;
}

.msg:not(:empty) {
  display: block;
}

.msg.error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.msg.success {
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid rgba(27, 172, 93, 0.2);
}

/* Datasets */
.datasets {
  display: grid;
  gap: 12px;
}

.dataset-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.2s;
}

.dataset-row:hover {
  border-color: var(--brand);
}

.dataset-info {
  display: flex;
  gap: 12px;
  align-items: center;
}

.pill {
  padding: 4px 10px;
  background: #f1f5f9;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.pill.active {
  background: var(--brand-soft);
  color: var(--brand);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: 24px;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}
