:root {
  --bg: #faf9f5;
  --surface: #ffffff;
  --text: #2d2a25;
  --text-light: #6b665f;
  --accent: #c85a3e;
  --accent-soft: #e8c5bd;
  --border: #e5e0d9;
  --shadow-sm: 0 3px 10px rgba(0,0,0,0.06);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
  --radius: 12px;
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}

header {
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.top-bar {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

h1 {
  font-family: 'Playfair Display', serif;
  font-size: 2.1rem;
  color: var(--accent);
}

.btn {
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}

.btn-primary  { background: var(--accent); color: white; }
.btn-primary:hover  { background: #b44e35; }
.btn-outline   { background: white; border: 1px solid var(--border); }
.btn-outline:hover { background: #f8f6f2; }
.btn-danger    { background: #c94c4c; color: white; font-size: 0.85rem; padding: 0.4rem 0.9rem; }

main {
  max-width: 1400px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.8rem;
}

.recipe-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: transform 0.18s, box-shadow 0.18s;
  position: relative;
}

.recipe-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.12);
}

.recipe-image {
  height: 200px;
  background-size: cover;
  background-position: center;
}

.recipe-content {
  padding: 1.3rem 1.4rem;
}

.recipe-title {
  font-size: 1.28rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.meta {
  font-size: 0.92rem;
  color: var(--text-light);
  margin-bottom: 0.9rem;
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
}

.meta-item::before {
  content: "• ";
  color: var(--accent);
  margin-right: 0.3rem;
}

.ingredients {
  margin: 1rem 0 0.8rem;
  font-size: 0.94rem;
}

.ingredient-item {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid #f0ece5;
}

.ingredient-name { flex: 1; }
.ingredient-amount { font-weight: 500; color: var(--accent); white-space: nowrap; }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.tag {
  font-size: 0.82rem;
  padding: 0.35rem 0.8rem;
  background: #f0ece5;
  border-radius: 1rem;
  color: #5c5145;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-content {
  background: white;
  width: 90%;
  max-width: 580px;
  border-radius: var(--radius);
  padding: 1.8rem;
  max-height: 90vh;
  overflow-y: auto;
}

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

.close-btn {
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--text-light);
}

.form-group {
  margin-bottom: 1.3rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

input[type="text"],
input[type="number"],
input[type="url"],
textarea,
select {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
}

.ingredients-container {
  margin-bottom: 1.5rem;
}

.ingredient-row {
  display: grid;
  grid-template-columns: 3fr 1fr 1fr auto;
  gap: 0.8rem;
  margin-bottom: 0.7rem;
  align-items: center;
  /*
  border: 2px solid black;
  border-radius: 8px;
  padding-top: 4px;
  padding-bottom: 4px;
  */
}

.ingredient-row input[type="text"] { grid-column: 1; }
.ingredient-row input[type="number"] { grid-column: 2; }
.ingredient-row select { grid-column: 3; }

.remove-ingredient {
  grid-column: 4;
  background: #eee;
  border: none;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1.2rem;
}

#addIngredientBtn {
  padding: 0.6rem 1.2rem;
  background: #f0ece5;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

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

.loading, .error-msg {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-light);
}

.header-buttons {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  justify-content: center;
}

@media (max-width: 680px) {
  .top-bar {
    flex-direction: column;
    align-items: stretch;
  }
  h1 {
    text-align: center;
  }
  .ingredient-row {
    grid-template-columns: 2fr 1fr 1fr auto;
  }
}


.th_left{
  text-align: left;
}
.th_right{
  text-align: right;
}
.hidden_row{
  display: none;
}
table {
    width: 100%;
}
table .tr_header{
    text-decoration: underline;
}
table tr:nth-child(odd){
    background-color: #f9f9f9;
}
table tr:nth-child(even){
    background-color: #ffffff;
}
table, th, td{
    border: 1px solid;
    border-collapse: collapse;
}
th, td{
    padding: 5px;
}


/* Tabs for nutrition */
#dialog label, #dialog input { display:block; }
#dialog label { margin-top: 0.5em; }
#dialog input, #dialog textarea { width: 95%; }
#tabs { margin-top: 1em; }
#tabs li .ui-icon-close { float: left; margin: 0.4em 0.2em 0 0; cursor: pointer; }
#add_tab { cursor: pointer; }


