/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --slate-bg: #1e293b;
  --slate-dark: #0f172a;
  --slate-mid: #334155;
  --slate-light: #475569;
  --slate-text: #94a3b8;
  --white: #f1f5f9;
  --emerald: #10b981;
  --emerald-dark: #059669;
  --pink: #f472b6;
  --pink-dark: #ec4899;
  --red: #ef4444;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
}

html {
  font-size: 14px;
}

body {
  background: var(--slate-dark);
  color: var(--white);
  font-family: var(--sans);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Header === */
header {
  background: var(--slate-bg);
  border-bottom: 1px solid var(--slate-mid);
  padding: 1.5rem 2rem;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.accent {
  color: var(--emerald);
}

.tagline {
  color: var(--slate-text);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* === Main === */
main {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
}

/* === Input Section === */
.input-section {
  margin-bottom: 2rem;
}

.input-section label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--white);
}

.input-row {
  display: flex;
  gap: 0.75rem;
}

.input-row input {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: var(--mono);
  background: var(--slate-bg);
  border: 1px solid var(--slate-mid);
  border-radius: 6px;
  color: var(--white);
  outline: none;
  transition: border-color 0.2s;
}

.input-row input:focus {
  border-color: var(--emerald);
}

.input-row input::placeholder {
  color: var(--slate-light);
}

.input-row button {
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  background: var(--emerald);
  color: var(--slate-dark);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.input-row button:hover {
  background: var(--emerald-dark);
}

.input-row button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.input-hint {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--slate-light);
}

/* === Results Section === */
.results-section {
  margin-bottom: 2rem;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.results-header h2 {
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.5rem;
  padding: 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--mono);
  background: var(--pink);
  color: var(--slate-dark);
  border-radius: 999px;
}

.csv-btn {
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--slate-mid);
  color: var(--white);
  border: 1px solid var(--slate-light);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.csv-btn:hover {
  background: var(--emerald);
  color: var(--slate-dark);
  border-color: var(--emerald);
}

/* === Table === */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--slate-mid);
  border-radius: 8px;
  background: var(--slate-bg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.85rem;
}

thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

thead tr {
  background: var(--slate-dark);
  border-bottom: 2px solid var(--emerald);
}

th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 700;
  color: var(--emerald);
  white-space: nowrap;
  user-select: none;
}

th.sortable {
  cursor: pointer;
}

th.sortable:hover {
  color: var(--pink);
}

th.sort-asc .sort-arrow::after {
  content: ' \25B2';
}

th.sort-desc .sort-arrow::after {
  content: ' \25BC';
}

td {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--slate-mid);
  color: var(--slate-text);
  white-space: nowrap;
}

tr:hover td {
  background: rgba(16, 185, 129, 0.05);
  color: var(--white);
}

td a {
  color: var(--pink);
  text-decoration: none;
}

td a:hover {
  text-decoration: underline;
}

/* Confidence badges */
.conf-high {
  color: var(--emerald);
  font-weight: 600;
}

.conf-medium {
  color: #fbbf24;
  font-weight: 600;
}

.conf-low {
  color: var(--red);
  font-weight: 600;
}

/* === History Section === */
.history-section {
  margin-bottom: 2rem;
}

.history-section h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--slate-bg);
  border: 1px solid var(--slate-mid);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.history-item:hover {
  border-color: var(--emerald);
}

.history-companies {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--white);
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--slate-light);
}

.history-meta .badge {
  font-size: 0.7rem;
  height: 1.25rem;
  min-width: 1.5rem;
}

.empty-state {
  color: var(--slate-light);
  font-style: italic;
  text-align: center;
  padding: 2rem;
}

/* === Footer === */
footer {
  background: var(--slate-bg);
  border-top: 1px solid var(--slate-mid);
  padding: 2rem;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  text-align: center;
}

.signup-block {
  margin-bottom: 1.5rem;
}

.signup-block h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--white);
}

.subscribe-form {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  max-width: 400px;
  margin: 0 auto;
}

.subscribe-form input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  background: var(--slate-dark);
  border: 1px solid var(--slate-mid);
  border-radius: 6px;
  color: var(--white);
  outline: none;
}

.subscribe-form input:focus {
  border-color: var(--emerald);
}

.subscribe-form button {
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--emerald);
  color: var(--slate-dark);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.subscribe-form button:hover {
  background: var(--emerald-dark);
}

.sub-msg {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.sub-msg.success {
  color: var(--emerald);
}

.sub-msg.error {
  color: var(--red);
}

.footer-copy {
  font-size: 0.8rem;
  color: var(--slate-light);
}

.footer-copy a {
  color: var(--pink);
  text-decoration: none;
}

.footer-copy a:hover {
  text-decoration: underline;
}

/* === Utilities === */
.hidden {
  display: none !important;
}

/* === Responsive === */
@media (max-width: 768px) {
  main {
    padding: 1rem;
  }

  .input-row {
    flex-direction: column;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .subscribe-form {
    flex-direction: column;
  }
}
