:root {
  --ground: #f5f5f4;
  --surface: #ffffff;
  --ink: #111111;
  --muted: #57534e;
  --line: #d6d3d1;
  --strong: #111111;
  --on-strong: #ffffff;
  --ok: #166534;
  --warn: #92400e;
  --bad: #991b1b;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: system-ui, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

.column { display: grid; gap: 16px; min-width: 0; }
.side { position: sticky; top: 16px; display: grid; gap: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.narrow { max-width: 420px; margin: 48px auto; }
.muted { color: var(--muted); font-size: 14px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.grow { flex: 1 1 180px; min-width: 0; }
.spread { justify-content: space-between; }

label { display: grid; gap: 4px; font-weight: 600; font-size: 14px; }

input, select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #78716c;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}

input[type="range"] { padding: 0; min-height: 24px; accent-color: var(--strong); }
input[type="checkbox"] { width: 20px; min-height: 20px; accent-color: var(--strong); }

.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; }

button {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:hover { background: #e7e5e4; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--strong); color: var(--on-strong); }
button.primary:hover { background: #333333; }
button.danger { color: var(--bad); border-color: var(--bad); }
button.small { min-height: 34px; padding: 4px 10px; font-size: 14px; }

:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }

.message { padding: 10px 12px; border-radius: 8px; font-weight: 600; border: 1px solid; }
.message.error { color: var(--bad); border-color: var(--bad); }
.message.ok { color: var(--ok); border-color: var(--ok); }

.state { font-weight: 700; }
.state.ok { color: var(--ok); }
.state.warn { color: var(--warn); }
.state.bad { color: var(--bad); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { display: grid; gap: 2px; }
.stat b { font-size: 15px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; }
.table-box { overflow-x: auto; }

.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.item input { flex: 1 1 140px; min-width: 0; }
.tag { font-size: 12px; color: var(--muted); }

.code { font-size: 22px; letter-spacing: 3px; direction: ltr; text-align: center; }

.draft { position: sticky; bottom: 0; background: var(--surface); border: 1px solid var(--strong); border-radius: 12px; padding: 12px 16px; }

/* תצוגה מקדימה */
.phone-frame {
  width: 320px;
  height: 660px;
  overflow: hidden;
  border: 8px solid #292524;
  border-radius: 28px;
  background: #000;
  position: relative;
}

.phone {
  width: 392px;
  height: 809px;
  transform: scale(0.776);
  transform-origin: top right;
  position: absolute;
  top: 0;
  right: 0;
  overflow: hidden;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
}

.p-head { display: flex; justify-content: space-between; align-items: center; }
.p-button {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-style: solid;
  border-width: 3px;
  border-radius: 28px;
  flex: none;
}
.p-stack { flex-direction: column; align-items: flex-start; gap: 8px; }
.p-disc { display: flex; align-items: center; justify-content: center; border-radius: 50%; flex: none; }
.p-center { justify-content: center; }
.p-row { display: flex; gap: 10px; align-items: center; }
.p-half { flex: 1 1 0; }
.p-page { flex: 1 1 0; }
.p-more { flex: none; }

@media (max-width: 860px) {
  .page { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; order: -1; justify-items: center; }
}
