:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1d2733;
  --muted: #5f6b78;
  --border: #d5dbe1;
  --accent: #1f6fb2;
  --accent-text: #ffffff;
  --error: #b3261e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Segoe UI", sans-serif;
  font-size: 16px;
}

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.top h1 { margin: 0; font-size: 20px; }
.logo { height: 56px; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 48px;
}

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field span { font-size: 14px; color: var(--muted); }
input, select {
  width: 100%;
  padding: 10px;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}
.row-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sizes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field[hidden] { display: none; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row-price { text-align: left; font-weight: bold; min-height: 1.2em; }
.row-price .muted { font-weight: normal; color: var(--muted); font-size: 14px; }

button {
  font: inherit;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}
button.secondary { background: transparent; color: var(--accent); }
button.link { border: none; background: none; color: var(--accent); padding: 4px 8px; }
button:disabled { opacity: 0.6; cursor: wait; }
#add-row { width: 100%; }

.summary {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.sub-line { display: flex; justify-content: space-between; color: var(--muted); margin-bottom: 4px; }
.total-line { display: flex; justify-content: space-between; font-size: 22px; margin-top: 8px; }
.error { color: var(--error); margin-top: 8px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }

.sizes > *, .options > * { min-width: 0; }

/* PDF layout: rendered off-screen at A4 width, then captured. The host does
   the hiding, because html2pdf copies .pdf and its styles when capturing. */
.pdf-host { position: fixed; top: 0; left: -10000px; }
.pdf {
  width: 794px;
  padding: 40px;
  background: #fff;
  color: #000;
  direction: rtl;
  font-family: Arial, sans-serif;
  font-size: 14px;
}
.pdf-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #000; padding-bottom: 12px; }
.pdf-head img { height: 100px; }
.pdf h2 { margin: 0 0 4px; font-size: 24px; }
.pdf-meta { margin: 16px 0; line-height: 1.6; }
.pdf table { width: 100%; border-collapse: collapse; }
.pdf th, .pdf td { border: 1px solid #999; padding: 6px; text-align: right; vertical-align: top; }
.pdf th { background: #eee; }
.pdf .num { text-align: left; white-space: nowrap; }
.pdf-sums { margin-top: 16px; margin-right: auto; width: 280px; }
.pdf-sums div { display: flex; justify-content: space-between; padding: 2px 0; }
.pdf-sums .pdf-total { font-size: 20px; font-weight: bold; border-top: 2px solid #000; margin-top: 4px; padding-top: 6px; }
