:root {
  --bg: #0e0e0f;
  --surface: #161618;
  --surface2: #1e1e21;
  --surface3: #252528;
  --border: rgba(255,255,255,0.07);
  --accent: #d4943a;
  --accent2: #e8b86d;
  --accent-dim: rgba(212,148,58,0.15);
  --green: #4caf82;
  --green-dim: rgba(76,175,130,0.12);
  --red: #e05555;
  --red-dim: rgba(224,85,85,0.12);
  --blue: #5b9bd5;
  --text: #f0ede8;
  --text2: #9e9b96;
  --text3: #5e5c58;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── HEADER ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.logo span { color: var(--text); }
.logo-sub {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-left: 0.75rem;
  margin-top: 2px;
}

/* ── NAV TABS ── */
.nav {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  background: var(--surface2);
  padding: 4px;
  border-radius: 10px;
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  border: none;
  background: transparent;
  color: var(--text2);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}
.nav-btn:hover { color: var(--text); background: var(--surface3); }
.nav-btn.active { background: var(--accent); color: #fff; }
.nav-btn .icon { font-size: 1rem; }

/* ── LAYOUT ── */
.main { padding: 2rem; max-width: 1400px; margin: 0 auto; }

/* ── PANELS ── */
.panel { display: none; }
.panel.active { display: block; }

/* ── PAGE TITLE ── */
.page-title {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}
.page-sub { color: var(--text2); font-size: 0.9rem; margin-bottom: 2rem; }

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── GRID ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

/* ── FORM ELEMENTS ── */
.form-group { margin-bottom: 1rem; }
label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 0.4rem;
  letter-spacing: 0.02em;
}
input, select, textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  transition: border-color 0.15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: var(--surface3);
}
select option { background: #1e1e21; }
textarea { resize: vertical; min-height: 90px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface3); }
.btn-danger { background: var(--red-dim); color: var(--red); border: 1px solid rgba(224,85,85,0.2); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-green { background: var(--green-dim); color: var(--green); border: 1px solid rgba(76,175,130,0.2); }
.btn-green:hover { background: var(--green); color: #fff; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
}
td { padding: 0.65rem 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
.mono { font-family: 'DM Mono', monospace; font-size: 0.82rem; }

/* ── BADGE ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-amber { background: var(--accent-dim); color: var(--accent); }
.badge-blue { background: rgba(91,155,213,0.12); color: var(--blue); }

/* ── STAT CARDS ── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}
.stat-label { font-size: 0.72rem; color: var(--text2); font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.4rem; }
.stat-value { font-family: 'DM Mono', monospace; font-size: 1.8rem; font-weight: 500; color: var(--text); line-height: 1; }
.stat-value.green { color: var(--green); }
.stat-value.amber { color: var(--accent); }
.stat-value.red { color: var(--red); }
.stat-sub { font-size: 0.78rem; color: var(--text3); margin-top: 0.3rem; }

/* ── UPLOAD ZONE ── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface2);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.upload-icon { font-size: 3rem; margin-bottom: 1rem; }
.upload-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.4rem; }
.upload-sub { font-size: 0.82rem; color: var(--text2); }

/* ── VOICE ── */
.voice-area {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}
.mic-btn {
  width: 90px; height: 90px;
  border-radius: 50%;
  border: 2px solid rgba(212,148,58,0.3);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 2.5rem;
  cursor: pointer;
  transition: all 0.2s;
  margin: 1rem auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mic-btn:hover { background: var(--accent); color: #fff; transform: scale(1.05); }
.mic-btn.recording {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224,85,85,0.4); }
  50% { box-shadow: 0 0 0 16px rgba(224,85,85,0); }
}
.voice-transcript {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  min-height: 120px;
  text-align: left;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text);
  margin-top: 1rem;
  white-space: pre-wrap;
}

/* ── INGREDIENT ROW ── */
.ingredient-row {
  display: grid;
  grid-template-columns: 2fr 80px 100px 80px 90px 90px 36px;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.ingredient-row input, .ingredient-row select {
  padding: 0.45rem 0.6rem;
  font-size: 0.82rem;
}

/* ── ESCANDALLO RESULT ── */
.escandallo-result {
  background: linear-gradient(135deg, var(--surface2) 0%, var(--surface3) 100%);
  border: 1px solid rgba(212,148,58,0.25);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.result-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.result-line:last-child { border-bottom: none; }
.result-line.total { font-size: 1rem; font-weight: 600; padding-top: 0.75rem; }
.result-line.pvp { color: var(--accent); font-size: 1.1rem; font-weight: 700; }

/* ── FC DISPLAY ── */
.fc-display {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  border: 2px solid;
  min-width: 110px;
}
.fc-display.good { border-color: var(--green); background: var(--green-dim); }
.fc-display.ok   { border-color: var(--accent); background: var(--accent-dim); }
.fc-display.bad  { border-color: var(--red);    background: var(--red-dim); }
.fc-pct { font-family: 'DM Mono', monospace; font-size: 2rem; font-weight: 500; }
.fc-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; opacity: 0.7; }

/* ── SEARCH ── */
.search-bar { position: relative; margin-bottom: 1.25rem; }
.search-bar input { padding-left: 2.5rem; }
.search-bar .search-icon { position: absolute; left: 0.8rem; top: 50%; transform: translateY(-50%); color: var(--text3); font-size: 0.9rem; }

/* ── LOADER ── */
.loader {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(212,148,58,0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── PARSED ITEM ── */
.parsed-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem;
  background: var(--surface3);
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  gap: 1rem;
}
.parsed-item input { background: var(--surface2); width: auto; flex: 1; padding: 0.3rem 0.5rem; font-size: 0.8rem; }

/* ── EMPTY ── */
.empty { text-align: center; padding: 3rem 1rem; color: var(--text3); }
.empty .e-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty p { font-size: 0.88rem; }

/* ── TOAST ── */
#toast {
  position: fixed;
  bottom: 2rem; right: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.25s;
  pointer-events: none;
  max-width: 320px;
}
#toast.show  { opacity: 1; transform: translateY(0); }
#toast.success { border-color: var(--green); color: var(--green); }
#toast.error   { border-color: var(--red);   color: var(--red); }
#toast.info    { border-color: var(--accent); color: var(--accent); }

/* ── DIVIDER ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ── HELPERS ── */
.flex         { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1  { gap: 0.5rem; }
.gap-2  { gap: 1rem; }
.mb-1   { margin-bottom: 0.5rem; }
.mb-2   { margin-bottom: 1rem; }
.mb-3   { margin-bottom: 1.5rem; }
.mt-1   { margin-top: 0.5rem; }
.mt-2   { margin-top: 1rem; }
.w-full { width: 100%; }
.text-sm    { font-size: 0.8rem; }
.text-xs    { font-size: 0.72rem; }
.text-muted { color: var(--text2); }
.text-accent { color: var(--accent); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.font-mono   { font-family: 'DM Mono', monospace; }
.font-bold   { font-weight: 600; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .ingredient-row { grid-template-columns: 1fr 60px 80px 60px 70px 70px 30px; }
}
@media (max-width: 640px) {
  .header { padding: 0 1rem; flex-wrap: wrap; height: auto; gap: 0.5rem; padding-top: 0.5rem; padding-bottom: 0.5rem; }
  .main   { padding: 1rem; }
  .nav-btn .nav-label { display: none; }
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }
