:root {
  --primary: #cc8016;
  --bg: #f5f7fb;
  --text: #0f172a;
  --card-bg: #ffffff;
  --border: #e2e8f0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #fefce8, #eff6ff 45%, #f5f7fb 80%);
  color: var(--text);
}

/* AUTH */

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-card {
  background: rgba(255,255,255,0.94);
  padding: 26px 28px;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(15,23,42,0.16);
  width: 380px;
  backdrop-filter: blur(10px);
}

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.auth-subtitle {
  margin: 0 0 16px;
  color: #6b7280;
  font-size: 14px;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.auth-card input[type="email"],
.auth-card input[type="password"],
.auth-card input[type="text"] {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 9px 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.auth-card input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(204,128,22,0.25);
}

.auth-error {
  background: #fef2f2;
  color: #b91c1c;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 10px;
}

.btn-primary, .btn-secondary {
  border-radius: 999px;
  border: none;
  padding: 9px 12px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 100px;
}

.btn-primary {
  background: linear-gradient(135deg, #f59e0b, #cc8016);
  color: #fff;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-secondary {
  background: #111827;
  color: #f9fafb;
}

/* APP SHELL */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: radial-gradient(circle at top, #020617, #020617 40%, #111827);
  color: #e5e7eb;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
}

.logo {
  font-weight: 700;
  font-size: 20px;
  margin-bottom: 26px;
  letter-spacing: 0.04em;
}
.logo span { color: var(--primary); }

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 9px 11px;
  border-radius: 10px;
  color: #9ca3af;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s, color 0.15s, transform 0.08s;
}
.nav-link.active,
.nav-link:hover {
  background: rgba(248,250,252,0.1);
  color: #f9fafb;
  transform: translateX(1px);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  font-weight: 600;
  font-size: 16px;
}

.user-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: #fef3c7;
  font-size: 13px;
  border: 1px solid #fde68a;
}

.view {
  padding: 22px;
}

/* CARDS */

.card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 18px;
  border: 1px solid rgba(148,163,184,0.4);
  box-shadow: 0 18px 40px rgba(15,23,42,0.04);
}

.card h2 {
  margin-top: 0;
  margin-bottom: 6px;
  font-size: 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* FORMS */

textarea,
input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 9px 11px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input#batch-name {
    flex-grow: 1;
    width: auto;
}

textarea:focus,
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(204,128,22,0.18);
}

.form-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

.hint {
  color: #9ca3af;
  font-weight: 400;
}

/* TABLE */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 8px;
}

th, td {
  padding: 8px 6px;
  border-bottom: 1px solid #e5e7eb;
}

th {
  text-align: left;
  color: #6b7280;
  font-weight: 500;
}

tr:hover {
  background: #f3f4ff;
}

/* GRID METRICS */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.metric-card {
  border-radius: 12px;
  padding: 10px 12px;
  background: #f9fafb;
  border: 1px dashed #e5e7eb;
}

.metric-score {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.metric-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.metric-text {
  font-size: 13px;
  color: #4b5563;
}

/* API KEY PANEL */

.api-key-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.api-key-row input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.small-note {
  font-size: 12px;
  color: #6b7280;
  margin-top: 6px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.status-pill.pending {
  background: #fef3c7;
  color: #92400e;
}

.status-pill.running {
  background: #e0f2fe;
  color: #075985;
}

.status-pill.completed {
  background: #ecfdf5;
  color: #166534;
}

.status-pill.failed {
  background: #fef2f2;
  color: #b91c1c;
}

.spinner-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}

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


/* MODAL */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 60px;
  z-index: 50;
}

.modal-dialog {
  max-width: 900px;
  width: 100%;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.btn-xs {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
}


.modal-header-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

#result-url {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.url-selector {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  max-width: 420px;
}



.inline-message {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.inline-message.success {
  background: #ecfdf5;
  color: #166534;
}

.inline-message.error {
  background: #fef2f2;
  color: #b91c1c;
}

.hidden { display: none; }
