/* Handyman admin. Light, calm surfaces; deep blue for action, amber for the deals themselves.
   Tokens first; components only ever use tokens. RTL throughout. */
@import url("/static/fonts/fonts.css");

:root {
  --bg: #F4F6FA;
  --surface: #FFFFFF;
  --surface-2: #F1F4F9;
  --ink: #0F172A;
  --ink-2: #334155;
  --muted: #5E6B7E;
  --line: #E3E8F0;
  --line-2: #D5DCE7;
  --primary: #1E40AF;
  --primary-2: #2650D6;
  --primary-soft: #EAF0FE;
  --on-primary: #FFFFFF;
  --accent: #B45309;
  --accent-soft: #FFF4E2;
  --gold: #D97706;
  --success: #15803D;
  --success-soft: #E7F6EC;
  --danger: #B91C1C;
  --danger-soft: #FCEBEB;
  --warn-soft: #FFF7E6;
  --ring: #2650D6;

  --font: "IBM Plex Sans Hebrew", "Segoe UI", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --pill: 999px;
  --sh-1: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  --sh-2: 0 10px 30px -12px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .05);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --t-fast: 140ms; --t: 220ms; --t-slow: 360ms;
  --side: 248px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.6 var(--font);
  direction: rtl; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.25; text-wrap: balance; margin: 0; color: var(--ink); }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.num, td.num, .price { font-family: var(--mono); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ltr { direction: ltr; unicode-bidi: isolate; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
.icon, .icon-lg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-lg { width: 22px; height: 22px; stroke-width: 1.75; }
.skip { position: absolute; inset-inline-start: 12px; top: -48px; background: var(--ink); color: #fff; padding: 8px 14px;
  border-radius: var(--r-sm); z-index: 100; transition: top var(--t) var(--ease); }
.skip:focus { top: 12px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100dvh; background: var(--surface); border-inline-start: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px; gap: 6px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 60%, #4F7BF7 100%); box-shadow: var(--sh-1); }
.brand b { display: block; font-size: 15px; }
.brand span { display: block; font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 44px; border-radius: 10px;
  color: var(--ink-2); font-weight: 500; position: relative; transition: background var(--t-fast) var(--ease), color var(--t-fast); }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--primary-soft); color: var(--primary); }
.nav a.on::before { content: ""; position: absolute; inset-inline-start: -14px; top: 10px; bottom: 10px; width: 3px;
  border-radius: 3px; background: var(--primary); }
.nav .count { margin-inline-start: auto; font: 600 12px/1 var(--mono); background: var(--accent); color: #fff;
  padding: 4px 7px; border-radius: var(--pill); }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center;
  color: var(--ink-2); font-weight: 600; }
.side-foot form { margin-inline-start: auto; }

.main { min-width: 0; padding: 26px clamp(16px, 3vw, 36px) 48px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.top p { margin: 4px 0 0; color: var(--muted); }
.btn.menu-btn { display: none; }

/* ---------- helpers ---------- */
.gap-top { margin-top: 16px; }
.gap-sm { margin-top: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: 18px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid-2 { grid-template-columns: 1.4fr 1fr; }
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font: 600 28px/1.1 var(--mono); font-variant-numeric: tabular-nums; }
.kpi.hot .value { color: var(--accent); }
.kpi-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.kpi.hot .kpi-ico { background: var(--accent-soft); color: var(--accent); }
.empty { color: var(--muted); padding: 22px; text-align: center; border: 1px dashed var(--line-2); border-radius: var(--r); background: var(--surface-2); }

/* ---------- controls ---------- */
.btn { --b: var(--surface); --c: var(--ink); appearance: none; border: 1px solid var(--line-2); background: var(--b); color: var(--c);
  font: 600 14px/1 var(--font); padding: 0 16px; min-height: 40px; border-radius: 10px; display: inline-flex; align-items: center;
  gap: 8px; cursor: pointer; text-decoration: none; transition: transform var(--t-fast) var(--ease), background var(--t-fast),
  box-shadow var(--t-fast), border-color var(--t-fast); touch-action: manipulation; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--ink-2); }
.btn:active { transform: scale(.97); }
.btn[disabled], .btn.is-busy { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { --b: var(--primary); --c: var(--on-primary); border-color: var(--primary); box-shadow: 0 6px 16px -8px rgba(30, 64, 175, .55); }
.btn-primary:hover { --b: var(--primary-2); border-color: var(--primary-2); }
.btn-good { --b: var(--success); --c: #fff; border-color: var(--success); }
.btn-ghost { --b: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { --b: var(--surface-2); border-color: transparent; }
.btn-danger { --c: var(--danger); }
.btn-danger:hover { --b: var(--danger-soft); border-color: var(--danger); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn-icon { padding: 0; width: 40px; justify-content: center; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label { font-weight: 500; font-size: 14px; color: var(--ink-2); display: block; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.help { font-size: 13px; color: var(--muted); margin-top: 6px; }
input[type=text], input[type=password], input[type=search], input[type=url], input[type=number], select, textarea {
  width: 100%; font: 400 15px/1.5 var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 4px rgba(38, 80, 214, .15); }
textarea { min-height: 260px; resize: vertical; line-height: 1.7; }
input.code { font: 600 26px/1 var(--mono); letter-spacing: .4em; text-align: center; direction: ltr; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 16px; }
.filters .field { margin: 0; min-width: 150px; }
.filters .grow { flex: 1 1 240px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); padding: 3px; border-radius: 11px; gap: 2px; }
.seg a { padding: 7px 14px; border-radius: 8px; color: var(--ink-2); font-weight: 500; font-size: 14px; min-height: 36px; display: inline-flex; align-items: center; }
.seg a.on { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }
.seg a:hover { text-decoration: none; }

/* ---------- chips & status ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 4px 10px;
  border-radius: var(--pill); background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip.record { background: #FFF1D6; color: #8A4B05; }
.chip.good { background: var(--success-soft); color: var(--success); }
.chip.expensive { background: var(--danger-soft); color: var(--danger); }
.chip.ok { background: var(--success-soft); color: var(--success); }
.chip.wait { background: var(--warn-soft); color: var(--accent); }
.dot-st { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-list { display: grid; gap: 8px; list-style: none; padding: 0; margin: 0; }
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px;
  background: var(--surface-2); border-radius: 10px; }

/* ---------- deal cards ---------- */
.deals { display: grid; gap: 12px; }
.deal { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; gap: 16px; align-items: center; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; box-shadow: var(--sh-1);
  transition: box-shadow var(--t) var(--ease), transform var(--t) var(--ease), border-color var(--t); }
.deal:hover { box-shadow: var(--sh-2); border-color: var(--line-2); }
.deal.record { border-inline-start: 4px solid var(--gold); }
.deal.good { border-inline-start: 4px solid var(--success); }
.thumb { width: 88px; height: 88px; border-radius: 12px; background: var(--surface-2); object-fit: contain; border: 1px solid var(--line); }
.thumb-ph { width: 88px; height: 88px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.deal > div { min-width: 0; }
.deal-t { overflow-wrap: anywhere; font-weight: 600; font-size: 15.5px; line-height: 1.4; margin-bottom: 6px; }
.deal-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 13.5px; align-items: center; }
.deal-meta .price { color: var(--ink); font-size: 17px; font-weight: 600; }
.deal-why { font-size: 13.5px; color: var(--ink-2); margin-top: 6px; }
.deal-act { display: flex; flex-direction: column; gap: 8px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-1); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: start; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 12px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: #F8FAFE; }
td .mini { width: 44px; height: 44px; border-radius: 9px; object-fit: contain; background: var(--surface-2); border: 1px solid var(--line); }
.t-title { font-weight: 500; max-width: 46ch; }
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }

/* ---------- draft editor ---------- */
.editor { display: grid; grid-template-columns: 1fr 380px; gap: 20px; align-items: start; }
.tg { background: #DCE7D3; background-image: radial-gradient(rgba(255, 255, 255, .35) 1px, transparent 1px); background-size: 14px 14px;
  border-radius: var(--r-lg); padding: 18px; position: sticky; top: 20px; }
.tg-msg { background: #fff; border-radius: 14px 14px 14px 4px; padding: 8px; box-shadow: 0 1px 1px rgba(0, 0, 0, .1); overflow: hidden; }
.tg-msg img { border-radius: 10px; width: 100%; max-height: 260px; object-fit: contain; background: #f5f5f5; margin-bottom: 8px; }
.tg-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.55; padding: 0 4px; }
.tg-btn { margin-top: 6px; background: rgba(255, 255, 255, .65); backdrop-filter: blur(6px); text-align: center; padding: 9px; border-radius: 10px;
  font-weight: 600; color: #2b6cb0; font-size: 14px; }
.counter { font: 500 12.5px/1 var(--mono); color: var(--muted); }
.counter.over { color: var(--danger); }
.problems { background: var(--warn-soft); border: 1px solid #F4D9A8; color: #7A3E06; border-radius: var(--r); padding: 12px 14px; margin-bottom: 16px; }
.problems li { margin: 2px 0; }

/* ---------- product page ---------- */
.p-head { display: grid; grid-template-columns: 140px 1fr; gap: 20px; align-items: start; }
.p-head img, .p-head .thumb-ph { width: 140px; height: 140px; border-radius: 16px; object-fit: contain; background: var(--surface-2); border: 1px solid var(--line); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 14px; }
.fact { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.fact span { display: block; font-size: 12.5px; color: var(--muted); }
.fact b { font: 600 17px/1.3 var(--mono); }
.fact b.text { font-family: var(--font); font-size: 15px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 6px; vertical-align: middle; }
.lg-post { background: var(--primary); } .lg-ksp { background: var(--success); } .lg-amz { background: var(--gold); } .lg-zap { background: var(--danger); border-radius: 0; height: 2px !important; }
.features li { margin-bottom: 6px; direction: ltr; text-align: left; color: var(--ink-2); }

/* ---------- charts ---------- */
.spark { width: 100%; height: auto; }
.spark .bar-all { fill: #E3E9F5; } .spark .bar-strong { fill: var(--primary); }
.chart { width: 100%; height: auto; }
.chart .grid { stroke: #EDF1F7; stroke-width: 1; }
.chart .axis, .spark .axis { fill: var(--muted); font: 11px var(--mono); }
.chart .zap { stroke: var(--danger); stroke-width: 1.5; stroke-dasharray: 6 5; }
.chart .zap-label { fill: var(--danger); font-family: var(--font); }
.chart .line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.s-ksp { stroke: var(--success); } .chart .line.s-amz { stroke: var(--gold); }
.chart .dot { stroke: #fff; stroke-width: 1.5; }
.chart .dot.s-post { fill: var(--primary); } .chart .dot.s-ksp { fill: var(--success); } .chart .dot.s-amz { fill: var(--gold); }
.chart .dot.is-best { stroke: var(--gold); stroke-width: 3; }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 85% -10%, #DCE6FF 0%, transparent 60%), radial-gradient(900px 500px at 0% 110%, #FFEFD6 0%, transparent 55%), var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--sh-2); padding: 30px 28px; }
.auth-card .brand { justify-content: center; padding-bottom: 8px; }
.auth-card h1 { text-align: center; font-size: 21px; margin: 6px 0 4px; }
.auth-card .lead { text-align: center; color: var(--muted); margin: 0 0 22px; }
.auth-card .btn { width: 100%; justify-content: center; min-height: 46px; }
.err { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.qr { display: grid; place-items: center; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 10px 0; }
.qr svg { width: 200px; height: 200px; }
.secret { font: 600 14px/1.6 var(--mono); background: var(--surface-2); padding: 8px 10px; border-radius: 8px; word-break: break-all; text-align: center; direction: ltr; }
.pw-wrap { position: relative; }
.pw-wrap .btn-icon { position: absolute; inset-inline-end: 4px; top: 2px; min-height: 40px; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); inset-inline-start: 50%; transform: translate(50%, 20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--sh-2); display: flex; gap: 10px;
  align-items: center; opacity: 0; z-index: 60; transition: opacity var(--t) var(--ease), transform var(--t) var(--ease); }
.toast.show { opacity: 1; transform: translate(50%, 0); }
[dir=ltr] .toast { transform: translate(-50%, 20px); }

/* ---------- dialog ---------- */
dialog { border: 0; border-radius: 18px; padding: 22px; width: min(420px, calc(100% - 32px)); box-shadow: var(--sh-2); color: var(--ink); }
dialog::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); }
dialog[open] { animation: pop var(--t) var(--ease); }
dialog p { color: var(--ink-2); }

/* ---------- motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes leave { to { opacity: 0; transform: translateX(-24px); } }
.rise > * { animation: rise var(--t-slow) var(--ease) both; }
.rise > *:nth-child(2) { animation-delay: 40ms; } .rise > *:nth-child(3) { animation-delay: 80ms; }
.rise > *:nth-child(4) { animation-delay: 120ms; } .rise > *:nth-child(5) { animation-delay: 160ms; }
.rise > *:nth-child(6) { animation-delay: 200ms; } .rise > *:nth-child(n+7) { animation-delay: 230ms; }
.is-leaving { animation: leave 200ms var(--ease) forwards; }
.spin { animation: spin 800ms linear infinite; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid-2, .editor { grid-template-columns: 1fr; }
  .tg { position: static; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(290px, 86vw); z-index: 50; transform: translateX(110%);
    transition: transform var(--t) var(--ease); box-shadow: var(--sh-2); }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .deal { grid-template-columns: 64px minmax(0, 1fr); }
  .main { overflow-x: clip; }
  .top h1 { font-size: 21px; }
  .deal .thumb, .deal .thumb-ph { width: 64px; height: 64px; }
  .deal-act { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .p-head { grid-template-columns: 1fr; }
}
