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

html { height: 100%; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #222533;
  --border:    #2e3148;
  --accent:    #5b7cfa;
  --accent-h:  #7a96ff;
  --green:     #3ecf8e;
  --red:       #f87171;
  --text:      #e2e4f0;
  --muted:     #6b7280;
  --radius:    10px;
  --font:      'Inter', system-ui, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 1rem 0.5rem;
  gap: 0.5rem;
}

header {
  width: 100%;
  max-width: none;
  flex-shrink: 0;
}

header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

header h1 span { color: var(--accent); }

header p {
  color: var(--muted);
  margin-top: 0.3rem;
  font-size: 0.9rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: none;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 0.85rem 1rem;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.tab-btn:hover { color: var(--text); background: var(--surface2); }
.tab-btn.active { color: var(--accent); border-bottom: 2px solid var(--accent); }

.tab-panel { display: none; padding: 1.5rem; overflow-y: auto; flex: 1; min-height: 0; }
.tab-panel.active { display: flex; flex-direction: column; }

/* Form elements */
label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

textarea, input[type="text"], input[type="file"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  padding: 0.7rem 0.9rem;
  outline: none;
  transition: border-color 0.15s;
  resize: vertical;
}

textarea:focus, input[type="text"]:focus { border-color: var(--accent); }

input[type="file"] {
  font-family: var(--font);
  cursor: pointer;
  padding: 0.5rem 0.9rem;
}

.field { margin-bottom: 1.1rem; }

.row { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.1rem; }
.row .field { flex: 1; margin-bottom: 0; }

/* OR divider */
.divider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1rem 0;
  color: var(--muted);
  font-size: 0.8rem;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.3rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

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

/* Status / result area */
.result-box {
  margin-top: 1.2rem;
  border-radius: 6px;
  padding: 1rem;
  font-size: 0.85rem;
  display: none;
}

.result-box.visible { display: block; }
.result-box.success { background: rgba(62,207,142,0.08); border: 1px solid rgba(62,207,142,0.3); color: var(--green); }
.result-box.error   { background: rgba(248,113,113,0.08); border: 1px solid rgba(248,113,113,0.3); color: var(--red); }
.result-box.info    { background: var(--surface2); border: 1px solid var(--border); color: var(--text); }

.result-box pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Answer text */
.answer-text {
  line-height: 1.7;
  font-size: 0.95rem;
  margin-bottom: 0.8rem;
  color: var(--text);
}

/* Table */
.table-wrap { overflow-x: auto; margin-top: 1rem; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

th {
  background: var(--surface2);
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 0.55rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

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

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Config banner */
.config-banner {
  background: rgba(91,124,250,0.1);
  border: 1px solid rgba(91,124,250,0.3);
  border-radius: 6px;
  padding: 0.7rem 1rem;
  font-size: 0.82rem;
  color: var(--accent-h);
  width: 100%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Select */
select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.7rem 0.9rem;
  outline: none;
  cursor: pointer;
  appearance: none;
  transition: border-color 0.15s;
}
select:focus { border-color: var(--accent); }
select[multiple] { padding: 0.3rem 0; }
select[multiple] option { padding: 0.35rem 0.9rem; }
select[multiple] option:checked { background: var(--accent); color: #fff; }

/* Excel preview panel */
.excel-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.2rem;
  background: var(--surface2);
  margin-bottom: 1.1rem;
}

/* Column type badge shown in preview table headers */
.type-badge {
  display: inline-block;
  margin-top: 0.2rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(91,124,250,0.15);
  color: var(--accent-h);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Row/column count shown above preview table */
.preview-info {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--surface2);
  color: var(--muted);
  margin-left: 0.4rem;
  vertical-align: middle;
}
