/* ===== Base ===== */
* { box-sizing: border-box; }

:root{
  --bg: #0b1020;
  --panel: #121a33;
  --panel2: #162047;

  --stroke: rgba(255,255,255,.09);
  --text: #e9ecff;
  --muted: rgba(233,236,255,.65);

  --accent: #7b61ff;
  --accent2: #ff5aa5;

  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --radius: 18px;

  --control-h: 48px;
}

body{
  margin: 0;
  font-family: system-ui, Arial, sans-serif;
  background: radial-gradient(1200px 800px at 50% -20%, rgba(123,97,255,.18), transparent 55%),
              radial-gradient(900px 700px at 10% 10%, rgba(255,90,165,.12), transparent 55%),
              var(--bg);
  color: var(--text);
}

.app{
  max-width: 720px;
  margin: 0 auto;
  padding: 14px;
}

h1{
  font-size: 22px;
  margin: 6px 0 14px;
  letter-spacing: .02em;
}

h2{
  font-size: 18px;
  margin: 0 0 10px;
  letter-spacing: .02em;
}

/* ===== Cards ===== */
.card{
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

/* ===== Controls ===== */
input, select, button{
  width: 100%;
  height: var(--control-h);
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,.22);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

input::placeholder{ color: rgba(233,236,255,.35); }

input:focus, select:focus{
  border-color: rgba(123,97,255,.55);
  box-shadow: 0 0 0 3px rgba(123,97,255,.15);
}

button{
  cursor: pointer;
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.10);
}

button:active{ transform: translateY(1px); }

button.danger{
  background: rgba(255, 80, 120, .22);
  border-color: rgba(255, 80, 120, .35);
}

.hint{
  margin: 10px 0 0;
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
}

/* ===== Form layout ===== */
.inputs{
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

/* вес + на порцию */
.weight-row{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: stretch;
  margin-top: 10px;
}

.weight-row > input,
.weight-row > label{
  height: var(--control-h);
}

.checkline{
  display:flex;
  align-items:center;
  gap:10px;
}

.checkline.inrow{
  margin: 0;
  padding: 0 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,.22);
  width: 100%;
}

.checkline.inrow input[type="checkbox"]{
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent2);
}

.checkline.inrow span{
  line-height: 1;
  white-space: nowrap;
  color: rgba(233,236,255,.85);
  font-weight: 700;
}

/* сетка под 2 кнопки (если где-то нужна) */
.actions{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

/* блок под одну кнопку ("Добавить") */
.add-wrap{ margin-top: 12px; }
.btn-full{ width: 100%; }

/* пресеты */
.preset-row{
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}

/* поле названия */
#title{
  width: 100%;
  margin-bottom: 10px;
}

/* ===== Inputs with emoji icon ===== */
.icon-input{
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
}

.ii-icon{
  height: var(--control-h);
  width: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.06);
  font-size: 20px;
}

.icon-input input{ height: var(--control-h); }

/* ===== Select ===== */
select{
  background: rgba(0,0,0,.22);
  border: 1px solid var(--stroke);
  color: var(--text);
}

select option{
  background: #121a33;
  color: #e9ecff;
}

select option:checked{ background: #1a2652; }

/* ===== Results header ===== */
.results-head{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.results-head h2{ margin: 0; }

.results-actions{
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Copy button theme */
.results-actions .btn{
  width: auto;
  height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.results-actions .btn.ghost{
  background: linear-gradient(
    135deg,
    rgba(120, 100, 255, 0.35),
    rgba(80, 160, 255, 0.25)
  );
  border: 1px solid rgba(140, 130, 255, 0.45);
  color: #fff;
}

/* Clear (X) button */
.icon-btn{
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  color: #fff;
  transition: 0.2s;
}

.icon-btn:hover{ transform: scale(1.05); }

.icon-btn.danger{
  background: linear-gradient(
    135deg,
    rgba(255, 90, 120, 0.35),
    rgba(255, 60, 90, 0.25)
  );
  border: 1px solid rgba(255, 120, 140, 0.45);
}

.icon-btn.danger:hover{
  background: linear-gradient(
    135deg,
    rgba(255, 90, 120, 0.55),
    rgba(255, 60, 90, 0.35)
  );
  border: 1px solid rgba(255, 140, 160, 0.7);
}

/* ===== Totals ===== */
.totals-grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 10px 0 14px;
}

.total-card{
  border-radius: 18px;
  padding: 16px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.total-card .t-ico{
  font-size: 26px;
  margin-bottom: 10px;
}

.total-card .t-title{
  font-weight: 800;
  letter-spacing: .06em;
  color: rgba(255,255,255,.85);
  font-size: 13px;
}

.total-card .t-val{
  margin-top: 8px;
  font-size: 34px;
  font-weight: 900;
  display:flex;
  gap: 10px;
  align-items: baseline;
}

.total-card .t-unit{
  font-size: 14px;
  color: var(--muted);
  font-weight: 700;
}

.t-k{ background: linear-gradient(135deg, rgba(255,140,60,.35), rgba(90,40,20,.25)); }
.t-b{ background: linear-gradient(135deg, rgba(70,210,140,.28), rgba(20,70,60,.22)); }
.t-j{ background: linear-gradient(135deg, rgba(200,90,220,.26), rgba(70,20,90,.20)); }
.t-u{ background: linear-gradient(135deg, rgba(90,150,255,.30), rgba(20,40,90,.20)); }

/* ===== List (product cards) ===== */
#list{
  display:flex;
  flex-direction: column;
  gap: 12px;
}

.item-card{
  background: rgba(255,255,255,.04);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 14px;
}

.item-head{
  display:flex;
  justify-content: space-between;
  align-items:flex-start;
  gap: 12px;
}

.item-title{
  font-weight: 900;
  font-size: 18px;
}

.item-sub{
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.item-actions{
  display:flex;
  gap: 8px;
}

/* action buttons in product card */
.act-btn{
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.10);
  color: var(--text);
  cursor: pointer;
}

.act-btn:active{ transform: translateY(1px); }

.act-btn.del{
  background: rgba(255,90,165,.22);
  border-color: rgba(255,90,165,.35);
}

.act-btn.rep{
  background: rgba(123,97,255,.22);
  border-color: rgba(123,97,255,.35);
}

.ico{
  width: 18px;
  height: 18px;
  display: block;
  fill: rgba(255,255,255,0.92);
}

/* macros grid in card */
.macro-grid{
  margin-top: 12px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.macro-pill{
  background: rgba(0,0,0,.18);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 10px 12px;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
}

.macro-left{
  display:flex;
  align-items:center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.macro-val{ font-weight: 900; }

/* ===== Responsive ===== */
@media (max-width: 520px) {
  .totals-grid{
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .total-card{
    padding: 12px;
    min-height: 110px;
  }
}

@media (min-width: 720px) {
  .inputs{
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .preset-row{
    grid-template-columns: 1fr auto;
    align-items: center;
  }
}

@media (min-width: 900px) {
  .totals-grid{
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }

  .total-card{ min-height: 120px; }
}
