:root {
  --primary: #00e5ff;
  --primary-hover: #00b8d4;
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
  --success: #10b981;
  --error: #ef4444;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  --radius: 12px;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 3rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: contain;
}

.brand-info h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #fff, var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 2rem;
  margin-bottom: 2rem;
  backdrop-filter: blur(10px);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

input, select, textarea {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  color: var(--text-main);
  font-family: inherit;
  font-size: 1rem;
  transition: all 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.2);
}

input[readonly] {
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-muted);
  cursor: not-allowed;
  border-color: var(--border);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 2rem;
}

button {
  cursor: pointer;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--primary);
  color: #000;
  border: none;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
}

.btn-highlight {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.1);
}

.btn-highlight:hover {
  background: rgba(0, 229, 255, 0.1);
}

.btn-delete {
  background: transparent;
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 0.4rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-delete:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--error);
  transform: scale(1.1);
}

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

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

th {
  text-align: left;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
}

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

tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top: 3px solid #000;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 10px 10px 30px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 1rem;
  transform: translateY(200%);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 1000;
}

.toast.show {
  transform: translateY(0);
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--error); }

/* Analysis styles */
.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.analysis-card {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  overflow: hidden;
}

.analysis-card.processing {
  border-color: var(--primary);
  opacity: 0.8;
}

.analysis-card .item-id {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 800;
  letter-spacing: 0.05em;
}

.analysis-card h3 {
  font-size: 1rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.analysis-card .justification {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.75rem;
  border-radius: 6px;
  border-left: 3px solid var(--primary);
}

.analysis-card .status-badge {
  align-self: flex-start;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.complete {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.status-badge.processing {
  background: rgba(0, 229, 255, 0.1);
  color: var(--primary);
}

.engine-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 229, 255, 0.1);
  border-top: 2px solid var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.analysis-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  font-style: italic;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.classification-tag {
  font-size: 0.75rem;
  margin-top: 0.5rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(255,255,255,0.05);
  padding-top: 0.5rem;
}

@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}
