:root {
  --bg:       #0f1117;
  --surface:  #1a1d27;
  --border:   #2a2d3e;
  --text:     #e2e8f0;
  --muted:    #8892a4;
  --accent:   #6366f1;
  --green:    #22c55e;
  --yellow:   #eab308;
  --red:      #ef4444;
  --blue:     #3b82f6;
  --purple:   #a855f7;
  --orange:   #f97316;
  --radius:   10px;
  --shadow:   0 4px 24px rgba(0,0,0,0.4);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* Header */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 1000px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.header-title { display: flex; align-items: center; gap: 1rem; }
.header-icon { font-size: 2rem; }
h1 { font-size: 1.3rem; font-weight: 700; }
.header-sub { font-size: 0.8rem; color: var(--muted); }

.status-badge {
  padding: 0.35rem 0.85rem; border-radius: 20px;
  font-size: 0.8rem; font-weight: 600; white-space: nowrap;
}
.status-checking { background: #2a2d3e; color: var(--muted); }
.status-ok       { background: rgba(34,197,94,0.15); color: var(--green); }
.status-error    { background: rgba(239,68,68,0.15); color: var(--red); }

/* Main */
main { max-width: 1000px; margin: 0 auto; padding: 2rem 1.5rem; display: flex; flex-direction: column; gap: 1.5rem; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.4rem; }
.section-hint { font-size: 0.85rem; color: var(--muted); margin-bottom: 1rem; }

/* Example buttons */
.examples-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.examples-label { font-size: 0.8rem; color: var(--muted); }
.example-btn {
  background: var(--border); color: var(--muted);
  border: 1px solid var(--border); border-radius: 5px;
  padding: 0.3rem 0.7rem; font-size: 0.78rem; cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.example-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Textarea */
textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; padding: 0.75rem;
  font-size: 0.9rem; font-family: inherit; resize: vertical;
  line-height: 1.5; margin-bottom: 1.2rem;
}
textarea:focus { outline: none; border-color: var(--accent); }

/* Submit button */
button#classify-btn {
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  padding: 0.75rem 2rem; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: background 0.2s, opacity 0.2s;
}
button#classify-btn:hover { background: #818cf8; }
button#classify-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Results grid */
.results-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 680px) { .results-grid { grid-template-columns: 1fr; } }

/* Category badge */
.category-badge {
  display: inline-block; padding: 0.5rem 1.2rem;
  border-radius: 6px; font-size: 1rem; font-weight: 700;
  margin-bottom: 0.8rem; text-transform: replace;
}
.cat-mechanical_failure      { background: rgba(239,68,68,0.15); color: var(--red); }
.cat-electrical_failure      { background: rgba(234,179,8,0.15);  color: var(--yellow); }
.cat-hydraulic_failure       { background: rgba(59,130,246,0.15); color: var(--blue); }
.cat-instrumentation_failure { background: rgba(168,85,247,0.15); color: var(--purple); }
.cat-preventive_maintenance  { background: rgba(34,197,94,0.15);  color: var(--green); }
.cat-operator_damage         { background: rgba(249,115,22,0.15); color: var(--orange); }

.confidence-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.8rem; }
.confidence-label { font-size: 0.82rem; color: var(--muted); }
.confidence-val { font-size: 1.2rem; font-weight: 700; }

.all-scores { display: flex; flex-direction: column; gap: 0.4rem; }
.score-row { display: grid; grid-template-columns: 160px 1fr 48px; align-items: center; gap: 0.5rem; font-size: 0.78rem; }
.score-name { color: var(--muted); }
.score-bar-track { background: var(--border); border-radius: 3px; height: 6px; overflow: hidden; }
.score-bar-fill  { height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.4s ease; }
.score-bar-fill.best { background: var(--green); }
.score-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* Extracted fields */
.extracted-fields { margin-top: 1.2rem; }
.extracted-fields h3 { font-size: 0.9rem; font-weight: 700; margin-bottom: 0.6rem; }
.fields-row { display: flex; gap: 0.5rem; margin-bottom: 0.35rem; font-size: 0.8rem; }
.field-key { color: var(--muted); min-width: 120px; }
.field-val { color: var(--text); }

/* Similar cases */
.similar-list { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 0.6rem; }
.similar-item { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.9rem; }
.similar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; }
.similar-id { font-size: 0.78rem; color: var(--muted); }
.similar-score { font-size: 0.78rem; font-weight: 700; color: var(--accent); }
.similar-category { font-size: 0.75rem; padding: 0.15rem 0.5rem; border-radius: 4px; margin-bottom: 0.4rem; display: inline-block; }
.similar-text { font-size: 0.8rem; color: var(--muted); line-height: 1.5; }
.empty-state { color: var(--muted); font-size: 0.85rem; }

/* Info grid */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.2rem; margin-top: 1rem; }
.info-item { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 1.2rem; }
.info-icon { font-size: 1.6rem; margin-bottom: 0.6rem; }
.info-item h3 { font-size: 0.9rem; font-weight: 700; margin-bottom: 0.4rem; }
.info-item p { font-size: 0.82rem; color: var(--muted); line-height: 1.55; }

/* Footer */
footer { text-align: center; padding: 2rem; font-size: 0.8rem; color: var(--muted); border-top: 1px solid var(--border); }
footer a { color: var(--accent); text-decoration: none; }

.hidden { display: none !important; }
