/* כספת קודים — פלדה מוברשת ופליז */
:root {
  --ground: #e6eaed;
  --surface: #f6f8f9;
  --raised: #ffffff;
  --ink: #141c22;
  --muted: #5a6771;
  --line: #cfd7dc;
  --line-strong: #b4c0c7;
  --accent: #8c5e12;
  --accent-hover: #754d0c;
  --accent-ink: #fff8ea;
  --accent-soft: #f1e3c6;
  --bad: #b0362d;
  --bad-soft: #f6dedb;
  --good: #2e7550;
  --shadow: 0 1px 2px rgb(20 28 34 / .06), 0 8px 24px -12px rgb(20 28 34 / .18);
  --scrim: rgb(13 18 21 / .45);

  --f-display: "Karantina", "Secular One", "Arial Narrow", sans-serif;
  --f-body: "IBM Plex Sans Hebrew", "Segoe UI", "Arial Hebrew", Arial, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --r: 10px;
  --r-sm: 6px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0d1215;
    --surface: #141b20;
    --raised: #1a232a;
    --ink: #e2e8eb;
    --muted: #8b99a3;
    --line: #25313a;
    --line-strong: #34434d;
    --accent: #d4a24a;
    --accent-hover: #e2b462;
    --accent-ink: #1b1405;
    --accent-soft: #2e2615;
    --bad: #e26a5f;
    --bad-soft: #3a1e1c;
    --good: #62b98a;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 12px 32px -12px rgb(0 0 0 / .6);
    --scrim: rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0d1215;
  --surface: #141b20;
  --raised: #1a232a;
  --ink: #e2e8eb;
  --muted: #8b99a3;
  --line: #25313a;
  --line-strong: #34434d;
  --accent: #d4a24a;
  --accent-hover: #e2b462;
  --accent-ink: #1b1405;
  --accent-soft: #2e2615;
  --bad: #e26a5f;
  --bad-soft: #3a1e1c;
  --good: #62b98a;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 12px 32px -12px rgb(0 0 0 / .6);
  --scrim: rgb(0 0 0 / .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 16px/1.55 var(--f-body);
  min-height: 100dvh;
}
h1, h2 { margin: 0; text-wrap: balance; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- סימן החוגה ---------- */
.dial-mark {
  --s: 56px;
  width: var(--s); height: var(--s);
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--surface) 0 38%, transparent 39%),
    repeating-conic-gradient(from -3deg, var(--accent) 0 6deg, transparent 6deg 30deg),
    radial-gradient(circle, transparent 0 62%, var(--line-strong) 63% 64%, transparent 65%);
  mask: radial-gradient(circle, #000 0 70%, transparent 71%);
  position: relative;
}
.dial-mark::after {
  content: ""; position: absolute; inset: 42% 48% 20% 48%;
  background: var(--ink); border-radius: 2px; transform-origin: 50% 0;
}
.dial-mark-sm { --s: 26px; display: inline-block; vertical-align: middle; margin-inline-end: 8px; }

.brand {
  font: 700 3.4rem/1 var(--f-display);
  letter-spacing: .01em;
}
.brand-sm { font-size: 2rem; display: flex; align-items: center; }

/* ---------- כפתורים ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--raised); color: var(--ink);
  font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--ink); background: var(--surface); border-color: var(--line); }
.btn-danger { background: transparent; border-color: transparent; color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad-soft); }
.btn:disabled { opacity: .55; cursor: progress; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--ground); color: var(--ink); }

/* ---------- מסך כניסה ---------- */
.gate { display: grid; place-items: center; padding: 24px 16px; }
.gate-panel {
  width: min(420px, 100%);
  display: grid; justify-items: center; gap: 18px; text-align: center;
  padding: 40px 28px 28px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow);
}
.gate-panel .dial-mark { --s: 72px; }
.gate-lead { color: var(--muted); max-width: 32ch; }
.gate-panel form { width: 100%; }
.btn-google { width: 100%; min-height: 50px; font-size: 1.05rem; background: var(--raised); }
.gate-foot { font-size: .8rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; width: 100%; }
.notice { width: 100%; padding: 10px 12px; border-radius: var(--r-sm); background: var(--ground); font-size: .95rem; }
.notice-bad { background: var(--bad-soft); color: var(--bad); font-weight: 500; }

/* ---------- אפליקציה ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner, .shell { width: min(820px, 100% - 32px); margin-inline: auto; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.topbar-user { display: flex; align-items: center; gap: 8px; min-width: 0; }
.who { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; }

.shell { padding-block: 24px 64px; display: grid; gap: 16px; }
.toolbar { display: flex; gap: 12px; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  padding-inline: 12px; min-height: 42px;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--r-sm); color: var(--muted);
}
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--ink); }

.ledger {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden;
}
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 44px 36px 36px; align-items: center; gap: 12px;
  cursor: copy; transition: background-color .15s;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row:hover { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.row:hover .code { border-color: var(--line); background: var(--raised); }
.row-copy .i-done, .row.copied .row-copy .i-copy { display: none; }
.row.copied .row-copy .i-done { display: block; }
.row.copied .row-copy { color: var(--good); }
.row-edit { cursor: pointer; }
.row-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row-name > div { display: grid; min-width: 0; }
.monogram {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font: 700 1.35rem/1 var(--f-display); padding-top: 2px;
}
.issuer { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.label { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.label:empty { display: none; }
.issuer, .label { unicode-bidi: plaintext; text-align: right; }

.code {
  direction: ltr; border: 1px solid transparent; background: none;
  padding: 4px 10px; border-radius: var(--r-sm);
  font: 600 1.85rem/1.1 var(--f-mono); letter-spacing: .04em;
  font-variant-numeric: tabular-nums; color: var(--ink);
  transition: color .2s, background-color .15s;
}
.code .gap { display: inline-block; width: .45em; }
.row.expiring .code { color: var(--bad); }
.row.copied .code { background: var(--accent-soft); border-color: transparent; }

.dial { width: 44px; height: 44px; }
.dial .tick { stroke: var(--line-strong); stroke-width: 2; stroke-linecap: round; }
.dial .tick.on { stroke: var(--accent); }
.row.expiring .dial .tick.on { stroke: var(--bad); }
.dial-num { font: 600 11px var(--f-mono); fill: var(--muted); font-variant-numeric: tabular-nums; }

.empty { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 48px 24px; }
.empty h2 { font: 700 2rem/1 var(--f-display); }
.empty p { color: var(--muted); max-width: 44ch; margin-bottom: 8px; }
.nomatch { padding: 24px; text-align: center; color: var(--muted); }

.toast {
  position: fixed; inset-inline: 0; bottom: 24px; margin-inline: auto; width: max-content; max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: var(--r-sm);
  background: var(--ink); color: var(--surface); font-weight: 500;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }

/* ---------- דיאלוגים ---------- */
.sheet {
  width: min(560px, 100% - 32px); max-height: calc(100dvh - 32px);
  padding: 0; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.sheet-sm { width: min(420px, 100% - 32px); }
.sheet::backdrop { background: var(--scrim); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.sheet h2 { font: 700 2rem/1 var(--f-display); }
.tabs { display: flex; gap: 4px; margin: 8px 20px 0; border-bottom: 1px solid var(--line); }
.tabs [role="tab"] {
  border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs [aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
[role="tabpanel"] { padding: 20px; }

.form { display: grid; gap: 14px; }
.sheet-sm .form { padding: 20px; }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 500; font-size: .92rem; }
.field em { color: var(--muted); font-style: normal; font-weight: 400; }
.field small { color: var(--muted); font-size: .82rem; }
.field input, .field select {
  min-height: 42px; padding: 0 12px; width: 100%;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--r-sm); outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.mono { font-family: var(--f-mono) !important; direction: ltr; text-align: left; letter-spacing: .05em; }
.advanced summary { cursor: pointer; color: var(--muted); font-size: .92rem; }
.advanced-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.form-error { color: var(--bad); background: var(--bad-soft); padding: 8px 12px; border-radius: var(--r-sm); font-size: .92rem; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.form-actions .grow { flex: 1; }

/* ---------- סריקה ---------- */
.scan-start { display: grid; justify-items: center; gap: 16px; text-align: center; }
.scan-lead { color: var(--muted); max-width: 44ch; }
.scan-sources { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.hint { font-size: .85rem; color: var(--muted); }

.cube-hero { width: 96px; height: 96px; position: relative; }
.cube-hero span, .cube { position: relative; }
.cube-hero span {
  position: absolute; inset: 0;
  background:
    linear-gradient(var(--accent), var(--accent)) top left / 22px 3px,
    linear-gradient(var(--accent), var(--accent)) top left / 3px 22px,
    linear-gradient(var(--accent), var(--accent)) top right / 22px 3px,
    linear-gradient(var(--accent), var(--accent)) top right / 3px 22px,
    linear-gradient(var(--accent), var(--accent)) bottom left / 22px 3px,
    linear-gradient(var(--accent), var(--accent)) bottom left / 3px 22px,
    linear-gradient(var(--accent), var(--accent)) bottom right / 22px 3px,
    linear-gradient(var(--accent), var(--accent)) bottom right / 3px 22px,
    repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 12px) center / 56px 56px no-repeat;
  background-repeat: no-repeat;
}

.cube {
  width: 170px; height: 170px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  outline: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  touch-action: none;
}
.cube > i { position: absolute; width: 26px; height: 26px; border: 3px solid var(--accent); }
.cube > i:nth-child(1) { top: -2px; left: -2px; border-width: 3px 0 0 3px; }
.cube > i:nth-child(2) { top: -2px; right: -2px; border-width: 3px 3px 0 0; }
.cube > i:nth-child(3) { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; }
.cube > i:nth-child(4) { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; }
.cube-beam {
  position: absolute; inset-inline: 8px; top: 8px; height: 2px;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
  animation: beam 1.8s ease-in-out infinite alternate;
}
.cube.hit { background: color-mix(in srgb, var(--good) 20%, transparent); }
.cube.hit > i { border-color: var(--good); }
.cube.hit .cube-beam { display: none; }
@keyframes beam { to { top: calc(100% - 10px); } }

.stage { display: grid; gap: 10px; }
.stage-view {
  position: relative; overflow: hidden; border-radius: var(--r-sm);
  background: #000; aspect-ratio: 16 / 10; max-height: 60dvh;
}
.stage-view video { width: 100%; height: 100%; object-fit: contain; display: block; }
.stage-view .cube { position: absolute; cursor: grab; box-shadow: 0 0 0 9999px rgb(0 0 0 / .35); }
.stage-view .cube:active { cursor: grabbing; }
.stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stage-status { color: var(--muted); font-size: .92rem; }

.floating-note {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 16px;
  padding: 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised);
}
.floating-note .cube-static { width: 64px; height: 64px; }
.floating-note .cube-static > i { width: 14px; height: 14px; }
.floating-note p { color: var(--muted); font-size: .92rem; }
.floating-note .btn { grid-column: 1 / -1; justify-self: start; }

.found-title { font-weight: 600; }
.import-rows { display: grid; gap: 12px; }
.import-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--raised); }
.import-row .meta { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); }

/* ---------- חלון הקובייה הצף (Document Picture-in-Picture) ---------- */
.pip {
  margin: 0; height: 100dvh; display: grid; grid-template-rows: 1fr auto; gap: 8px;
  padding: 10px; background: var(--surface); color: var(--ink); font: 400 14px/1.4 var(--f-body);
  user-select: none;
}
.pip .cube { width: 100%; height: 100%; min-height: 0; display: grid; place-items: center; }
.pip .cube canvas { max-width: 70%; max-height: 70%; image-rendering: pixelated; border-radius: 3px; }
.pip-status { text-align: center; font-weight: 500; }
.pip-status small { display: block; color: var(--muted); font-weight: 400; }
.pip-actions { display: flex; gap: 6px; justify-content: center; }
.pip .btn { min-height: 34px; padding: 0 12px; font-size: .9rem; }

/* ---------- טלפון ---------- */
@media (max-width: 600px) {
  .brand { font-size: 2.8rem; }
  .brand-sm { font-size: 1.7rem; }
  .who { display: none; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .btn { flex: 1; }
  .row { grid-template-columns: minmax(0, 1fr) 44px 36px 36px; gap: 6px 8px; padding: 12px 14px; }
  .row-name { grid-column: 1 / -1; }
  .code { justify-self: start; font-size: 1.7rem; padding-inline: 4px; }
  .advanced-grid { grid-template-columns: 1fr 1fr; }
  .import-row { grid-template-columns: 1fr; }
  .cube { width: 130px; height: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
