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

:root {
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --surface-alt: #F4F5F7;
  --border: #E2E4E9;
  --border-focus: #1A1A2E;
  --text-primary: #1A1A2E;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;
  --accent: #1A1A2E;
  --accent-light: #E8E8EF;
  --green: #059669;
  --green-bg: #ECFDF5;
  --amber: #D97706;
  --amber-bg: #FFFBEB;
  --red: #DC2626;
  --red-bg: #FEF2F2;
  --blue: #2563EB;
  --blue-bg: #EFF6FF;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.08);
  --font: 'DM Sans', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

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

.logo-mark {
  height: 36px;
  border-radius: 8px;
  overflow: hidden;
}

.logo-mark img {
  height: 100%;
  width: auto;
  display: block;
  border-radius: 8px;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.logo-text span {
  color: var(--text-tertiary);
  font-weight: 400;
  margin-left: 4px;
}

.header-badge {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-tertiary);
  background: var(--surface-alt);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 28px;
  background: var(--surface-alt);
  padding: 4px;
  border-radius: 10px;
  width: fit-content;
}

.tab {
  padding: 9px 20px;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 7px;
  transition: all 0.2s;
}

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

.tab.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Panels */
.panel { display: none; }
.panel.active { display: block; }

/* Input Section */
.input-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.input-card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-card-title .icon {
  width: 20px;
  height: 20px;
  background: var(--accent-light);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 200px 140px;
  gap: 12px;
  align-items: end;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus { border-color: var(--border-focus); }
.form-input::placeholder { color: var(--text-tertiary); }

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236B7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.btn-predict {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 24px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  height: fit-content;
}

.btn-predict:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-predict:active { transform: translateY(0); }
.btn-predict:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-predict.loading {
  position: relative;
  color: transparent;
}

.btn-predict.loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  top: 50%;
  left: 50%;
  margin: -9px 0 0 -9px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Results */
.results-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  animation: slideUp 0.3s ease;
}

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

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.results-title {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.results-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-tertiary);
  background: var(--surface-alt);
  padding: 3px 8px;
  border-radius: 4px;
}

.results-teaser {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 24px;
  text-align: left;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}

tbody td {
  font-size: 13.5px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-alt); }

.ctr-value {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 13px;
}

.ctr-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ctr-bar-track {
  flex: 1;
  height: 6px;
  background: var(--surface-alt);
  border-radius: 3px;
  overflow: hidden;
  max-width: 100px;
}

.ctr-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.ctr-high { color: var(--green); }
.ctr-high .ctr-bar-fill { background: var(--green); }
.ctr-mid { color: var(--amber); }
.ctr-mid .ctr-bar-fill { background: var(--amber); }
.ctr-low { color: var(--red); }
.ctr-low .ctr-bar-fill { background: var(--red); }

.platform-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 500;
}

.platform-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

/* Compare panel */
.compare-inputs {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.compare-row {
  display: grid;
  grid-template-columns: 40px 1fr 180px 40px;
  gap: 12px;
  align-items: center;
}

.compare-num {
  width: 32px;
  height: 32px;
  background: var(--accent-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.btn-icon {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-tertiary);
  transition: all 0.2s;
}

.btn-icon:hover { border-color: var(--red); color: var(--red); }

.btn-add {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 4px;
}

.btn-add:hover { border-color: var(--accent); color: var(--accent); }

.compare-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

/* Compare Results */
.compare-results {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.compare-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.compare-card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.compare-card-teaser {
  font-size: 14px;
  font-weight: 600;
}

.compare-card-avg {
  font-family: var(--mono);
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 6px;
}

.compare-card table { font-size: 13px; }
.compare-card thead th { padding: 10px 20px; font-size: 10.5px; }
.compare-card tbody td { padding: 10px 20px; }

/* History */
.history-list { display: flex; flex-direction: column; gap: 10px; }

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.history-item:hover {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-md);
}

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

.history-item-teaser {
  font-size: 14px;
  font-weight: 600;
}

.history-item-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-tertiary);
}

.history-item-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.history-item-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
}

.empty-state-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state-text {
  font-size: 14px;
}

/* Error */
.error-msg {
  background: var(--red-bg);
  color: var(--red);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  animation: slideUp 0.3s ease;
}

/* Platform checkboxes */
.platforms-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.platforms-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.platforms-toggle {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}

.platforms-toggle:hover { opacity: 0.7; }

.platforms-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.platform-checkbox {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  user-select: none;
}

.platform-checkbox:hover {
  border-color: var(--border-focus);
}

.platform-checkbox.checked {
  background: var(--accent-light);
  border-color: var(--accent);
}

.platform-checkbox input {
  display: none;
}

.platform-check-icon {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 10px;
  color: transparent;
  flex-shrink: 0;
}

.platform-checkbox.checked .platform-check-icon {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Responsive */
@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .compare-row { grid-template-columns: 32px 1fr 32px; }
  .compare-row select { display: none; }
  .header { flex-direction: column; gap: 12px; align-items: flex-start; }
}
