:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --primary-light: #d1fae5;
  --secondary: #3b82f6;
  --danger: #ef4444;
  --danger-dark: #b91c1c;
  --danger-light: #fee2e2;
  --dark: #0f172a;
  --dark-card: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --bg-main: #020617;
  --border: #334155;

  --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.15);
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);

  font-family: 'Inter', sans-serif;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* HEADER */
header {
  background: rgba(255, 255, 255, 0.05);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #10b981 0%, #3b82f6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo i {
  color: var(--primary);
  -webkit-text-fill-color: initial;
}

/* CONTAINER */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* CARDS */
.card {
  background: var(--dark-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-glow);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-main);
}

/* FILE UPLOAD */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(15, 23, 42, 0.4);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(16, 185, 129, 0.05);
}

.upload-icon {
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 1rem;
}

.upload-text {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* GRID LAYOUTS */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
}

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

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

input,
select {
  background: var(--dark);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: var(--dark);
}

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

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.btn-icon {
  padding: 0.5rem;
}

/* SEARCH AUTOCOMPLETE */
.search-container {
  position: relative;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--dark-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  display: none;
}

.search-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

.search-item:hover {
  background: rgba(16, 185, 129, 0.1);
}

.search-item-title {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.search-item-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* TABLES */
.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  padding: 1rem;
  background: rgba(15, 23, 42, 0.5);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  padding: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
}

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

/* KPI STATS */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-box {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.kpi-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* BADGES */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-primary {
  background: rgba(16, 185, 129, 0.2);
  color: var(--primary);
}

/* TABLA NUTRICIONAL OFICIAL (Styling Res 810) */
.tabla-oficial {
  background: #fff;
  color: #000;
  border: 3px solid #000;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  font-family: Arial, Helvetica, sans-serif;
}

.to-header {
  background: #000;
  color: #fff;
  text-align: center;
  padding: 0.5rem;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 1px;
}

.to-subheader {
  padding: 0.5rem;
  border-bottom: 8px solid #000;
  font-size: 0.85rem;
  text-align: center;
  line-height: 1.4;
}

.to-row {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid #999;
  font-size: 0.85rem;
}

.to-row.thick {
  border-bottom: 4px solid #000;
}

.to-row.med {
  border-bottom: 2px solid #000;
}

.to-row.bold {
  font-weight: bold;
}

.to-row.indent {
  padding-left: 1.5rem;
}

.to-row.indent2 {
  padding-left: 2.5rem;
}

.to-cals {
  text-align: center;
  border-bottom: 4px solid #000;
  padding: 0.5rem;
}

.to-cals-val {
  font-size: 2.5rem;
  font-weight: 900;
  line-height: 1;
}

.to-vd-header {
  font-size: 0.75rem;
  font-weight: bold;
  padding: 0.25rem 0.5rem;
  background: #000;
  color: #fff;
  display: flex;
  justify-content: space-between;
}

.to-footer {
  font-size: 0.65rem;
  padding: 0.5rem;
  line-height: 1.2;
}

/* SELLOS FRONTALES */
.sellos-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.sello-oct {
  width: 100px;
  height: 100px;
  background: #000;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #000;
  padding: 10px;
  margin: 2px;
}

.sello-oct-top {
  font-size: 0.6rem;
  font-weight: 700;
}

.sello-oct-main {
  font-size: 0.85rem;
  font-weight: 900;
  text-transform: uppercase;
  line-height: 1.1;
  margin-top: 2px;
}

/* ALERTS */
.alert {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.alert-info {
  background: rgba(59, 130, 246, 0.1);
  border-left: 4px solid var(--secondary);
}

/* MODAL */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--dark-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.modal-content::-webkit-scrollbar {
  width: 8px;
}

.modal-content::-webkit-scrollbar-track {
  background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

/* UTILS */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

/* --- EXTRACTED INLINE STYLES --- */

.header-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.column-gap-large {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.grid-span-2 {
  grid-column: span 2;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--text-main);
  font-weight: 600;
}

.checkbox-input {
  width: auto;
  height: 1.2rem;
  aspect-ratio: 1;
  accent-color: var(--primary);
}

.formulation-search-row {
  align-items: end;
  margin-bottom: 1.5rem;
}

.search-label {
  display: flex;
  justify-content: space-between;
}

.btn-link {
  color: var(--primary);
  font-size: 0.8rem;
  text-decoration: none;
}

.form-group-row {
  display: flex;
  flex-direction: row;
  gap: 1rem;
}

.flex-1 {
  flex: 1;
}

.btn-add {
  margin-bottom: 2px;
}

.sellos-section {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.sellos-title {
  font-size: 0.9rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.card-light {
  background: #e2e8f0;
}

.modal-title {
  font-size: 1.25rem;
  color: var(--text-main);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}

.mb-1 {
  margin-bottom: 1rem;
}

.section-title {
  margin: 1rem 0 0.5rem;
  color: var(--primary);
}

.grid-3-modal {
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-title-border {
  margin: 1.5rem 0 1rem;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.grid-4-modal {
  gap: 1rem;
  margin-bottom: 2rem;
}

.modal-footer {
  position: sticky;
  bottom: -2.5rem;
  background: var(--dark-card);
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.btn-full-width {
  width: 100%;
  font-size: 1.05rem;
  padding: 1rem;
}

/* Extracted Javascript Inline Styles */
#global-loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  font-size: 1.5rem;
}

.save-success-msg {
  padding: 1rem;
  color: var(--primary);
  font-weight: 600;
}

.td-name {
  font-weight: 500;
}

.no-sellos {
  color: var(--primary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sello-oct-bottom {
  font-size: 0.4rem;
  margin-top: 4px;
  border-top: 1px solid #fff;
  padding-top: 2px;
}

.sello-rec {
  background: #000;
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #000;
  padding: 12px 16px;
  margin: 2px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-weight: 900;
  font-size: 0.8rem;
  line-height: 1.1;
  max-width: 150px;
}

.sello-rec-bottom {
  font-size: 0.45rem;
  font-weight: 400;
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px solid #fff;
  width: 100%;
}

.empty-formulation {
  padding: 3rem;
}

.empty-vits {
  font-size: 0.7rem;
}

.to-cals-title {
  font-weight: bold;
  font-size: 0.85rem;
}

.to-cals-kj {
  font-size: 0.8rem;
}

.to-vits-header {
  padding: 0.25rem 0.5rem;
  background: #eee;
  font-weight: bold;
  font-size: 0.75rem;
}
