/* ==========================================================================
   ממשק ניהול
   ========================================================================== */

body { min-height: 100vh; }

.hidden { display: none !important; }

/* ---------------- התחברות ---------------- */

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(400px, 100%);
  padding: clamp(1.6rem, 5vw, 2.6rem);
  text-align: center;
}
.login-card h1 { font-size: 1.7rem; margin-bottom: 0.3em; }
.login-card p { color: var(--muted); margin: 0 0 1.6rem; font-size: 0.92rem; }
.login-card .field { text-align: start; margin-bottom: 0.9rem; }
.login-card .btn { width: 100%; margin-top: 0.5rem; padding: 0.75em; }

.err {
  color: #e08b76;
  font-size: 0.88rem;
  min-height: 1.3em;
  margin-top: 0.7rem;
}
:root[data-theme='day'] .err { color: #a83a22; }

/* ---------------- שלד ---------------- */

.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }

.side {
  border-inline-end: 1px solid var(--line-soft);
  padding: 1.4rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.side-brand { padding-inline: 0.5rem; }
.side-brand h1 { font-size: 1.15rem; line-height: 1.2; }
.side-brand span { font-size: 0.78rem; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 0.2rem; }
.nav button {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.62em 0.85em;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
  text-align: start;
  width: 100%;
  transition: background 0.14s, color 0.14s;
}
.nav button:hover { background: var(--panel); color: var(--text); }
.nav button.on { background: var(--panel-2); color: var(--gold-soft); box-shadow: inset 2px 0 0 var(--gold); }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.82rem; }
.side-foot .who { color: var(--muted); padding-inline: 0.5rem; }
.side-foot .who b { color: var(--text); display: block; font-size: 0.95rem; }

.main { padding: clamp(1.2rem, 3vw, 2.4rem); min-width: 0; }

.page { display: none; }
.page.on { display: block; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.3rem;
}
.page-head h2 { font-size: 1.45rem; }
.page-head p { color: var(--muted); font-size: 0.88rem; margin: 0.3em 0 0; }

/* ---------------- קופסאות ---------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 15px;
  padding: clamp(1rem, 2.4vw, 1.5rem);
  margin-bottom: 1.1rem;
}
.card > h3 {
  font-size: 1rem;
  color: var(--gold-soft);
  margin-bottom: 0.3em;
}
.card > .hint { color: var(--muted); font-size: 0.84rem; margin: 0 0 1.1rem; line-height: 1.55; }
.card > .hint:last-child { margin-bottom: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.9rem;
}
.grid .wide { grid-column: 1 / -1; }

.row { display: flex; gap: 0.6rem; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }
.row > .fit { flex: 0 0 auto; }

.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1.1rem; }

.check {
  display: flex;
  align-items: center;
  gap: 0.55em;
  padding: 0.5em 0;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 500;
}
.check input { width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--gold); cursor: pointer; }

.tag-list { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.6rem; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.32em 0.5em 0.32em 0.75em;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.85rem;
  background: var(--panel-2);
}
.tag button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}
.tag button:hover { color: #e08b76; }

.table-wrap { overflow-x: auto; margin: 0 -0.3rem; padding: 0 0.3rem; }
table { min-width: 560px; }
td .btn { white-space: nowrap; }

.lnk-cell { white-space: nowrap; }
.lnk-txt {
  display: block;
  direction: ltr;
  text-align: left;
  font-size: 0.7rem;
  color: var(--muted);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 0.3em;
  user-select: all;
}

.chip {
  display: inline-block;
  padding: 0.16em 0.6em;
  border-radius: 999px;
  font-size: 0.74rem;
  border: 1px solid var(--line);
  color: var(--muted);
}
.chip.gold { border-color: var(--gold); color: var(--gold-soft); }
.chip.off { opacity: 0.5; }

.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

.link-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.link-row:last-child { border-bottom: 0; }
.link-row .lr-name { font-weight: 700; min-width: 150px; }
.link-row .lr-url {
  flex: 1 1 240px;
  font-size: 0.82rem;
  color: var(--muted);
  direction: ltr;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.danger-zone { border-color: rgba(200, 84, 64, 0.4); }
.danger-zone > h3 { color: #e08b76; }
:root[data-theme='day'] .danger-zone > h3 { color: #a83a22; }

/* ---------------- מתרים ---------------- */

.me-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
}
.me-num { font-size: clamp(1.8rem, 6vw, 2.8rem); font-weight: 800; }
.me-of { color: var(--muted); font-size: 0.95rem; }
.me-of b { color: var(--gold); }
.me-pct { font-size: clamp(1.6rem, 5vw, 2.4rem); font-weight: 800; color: var(--gold-soft); text-align: center; }
.me-bar { height: 12px; border-radius: 99px; background: var(--line-soft); overflow: hidden; margin-top: 0.9rem; }
.me-bar span {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold) 55%, var(--gold-soft));
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.me-qr {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 1rem;
  font-size: 0.84rem;
}
.me-qr img {
  width: 120px;
  height: 120px;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}

/* ---------------- מוצרים ---------------- */

.pr-list { display: flex; flex-direction: column; gap: 0.6rem; }

.pr-item {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) auto;
  gap: 0.3rem 0.9rem;
  align-items: center;
  padding: 0.7rem;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  background: var(--panel-2);
}
.pr-thumb {
  grid-row: 1 / span 3;
  width: 86px;
  height: 66px;
  border-radius: 9px;
  background: var(--panel) center/cover no-repeat;
  border: 1px solid var(--line-soft);
  display: grid;
  place-items: center;
  color: var(--line);
  cursor: pointer;
}
.pr-thumb:hover { border-color: var(--gold); }
.pr-name { font-weight: 700; }
.pr-name small { color: var(--muted); font-weight: 500; margin-inline-start: 0.5em; font-size: 0.8rem; }
.pr-meta { font-size: 0.8rem; color: var(--muted); display: flex; gap: 0.8rem; flex-wrap: wrap; }
.pr-meta b { color: var(--text); }
.pr-bar { height: 6px; border-radius: 99px; background: var(--line-soft); overflow: hidden; grid-column: 2; }
.pr-bar span {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold) 60%, var(--gold-soft));
}
.pr-actions { grid-row: 1 / span 3; display: flex; flex-direction: column; gap: 0.35rem; }

@media (max-width: 620px) {
  .pr-item { grid-template-columns: 64px minmax(0, 1fr); }
  .pr-thumb { width: 64px; height: 52px; }
  .pr-actions { grid-row: auto; grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .pr-bar { grid-column: 1 / -1; }
}

/* ---------------- הודעות ---------------- */

.flash {
  position: fixed;
  inset-block-start: 1rem;
  inset-inline-end: 1rem;
  z-index: 99;
  padding: 0.75em 1.2em;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--gold);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  font-weight: 600;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  max-width: min(420px, 90vw);
}
.flash.show { opacity: 1; transform: none; }
.flash.bad { border-color: #c0563e; }

@media (max-width: 780px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: static;
    height: auto;
    border-inline-end: 0;
    border-bottom: 1px solid var(--line-soft);
    flex-direction: row;
    align-items: center;
    gap: 0.8rem;
    overflow-x: auto;
    padding: 0.8rem;
  }
  .side-brand { flex: 0 0 auto; }
  .nav { flex-direction: row; gap: 0.3rem; }
  .nav button { white-space: nowrap; padding: 0.5em 0.8em; }
  .side-foot { margin-top: 0; flex: 0 0 auto; flex-direction: row; align-items: center; }
  .side-foot .who b { display: inline; }
}