/* Editor UI */
:root {
  --bg: #EFE9E3;
  --panel: #FFFFFF;
  --ink: #232120;
  --muted: #7D766F;
  --line: #E4DCD3;
  --accent: #A9825F;
  --accent-ink: #fff;
  --field: #FAF7F4;
  --danger: #B4533F;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Talent', 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  direction: rtl;
  font-size: 14px;
}
button, input, select, textarea { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: 60px; padding: 0 18px;
  background: #111; color: #eee;
}
.topbar .brand { display: flex; align-items: center; gap: 12px; }
.topbar .brand img { height: 20px; }
.topbar .brand span { font-size: 13px; color: #b9b0a7; border-right: 1px solid #333; padding-right: 12px; }
.topbar .spacer { flex: 1; }
.topbar .status { font-size: 12px; color: #8f877f; min-width: 70px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel); cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.dark { background: #222; color: #eee; border-color: #333; }
.btn.dark:hover { border-color: var(--accent); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12px; }
.btn.icon { width: 28px; padding: 0; justify-content: center; }
.btn.danger { color: var(--danger); }

.layout { display: grid; grid-template-columns: 460px 1fr; height: calc(100vh - 60px); }
.editor { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 10px 12px 0; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: none; padding: 9px 11px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-size: 13px; }
.tab.on { color: var(--ink); border-color: var(--accent); font-weight: 600; }
.form { overflow-y: auto; padding: 18px 18px 60px; flex: 1; }
.form h4 { margin: 22px 0 10px; font-size: 12px; letter-spacing: .06em; color: var(--accent); font-weight: 600; }
.form h4:first-child { margin-top: 0; }
.hint { font-size: 12px; color: var(--muted); margin: -4px 0 12px; line-height: 1.5; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fld { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.fld > span { font-size: 12px; color: var(--muted); }
.fld input, .fld select, .fld textarea, .rep input, .rep textarea {
  width: 100%; border: 1px solid var(--line); background: var(--field); border-radius: 6px; padding: 8px 10px; outline: none;
}
.fld textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.fld input:focus, .fld select:focus, .fld textarea:focus, .rep input:focus, .rep textarea:focus { border-color: var(--accent); background: #fff; }
.chk { display: flex; align-items: center; gap: 8px; margin: 6px 0; cursor: pointer; }
.chk input { accent-color: var(--accent); width: 16px; height: 16px; }

.rep { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.rep .row { display: grid; gap: 6px; align-items: start; background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.rep .row input, .rep .row textarea { background: #fff; padding: 6px 8px; }
.rep .row textarea { min-height: 34px; resize: vertical; }
.rep .ctl { display: flex; gap: 4px; }
.rep.items .row { grid-template-columns: 1fr 64px 110px auto; }
.rep.items .row textarea { grid-column: 1 / 4; }
.rep.timeline .row { grid-template-columns: 1fr 70px auto; }
.rep.timeline .row input.ds { grid-column: 1 / 3; }
.rep.payments .row { grid-template-columns: 1fr 70px auto; }
.num-in { direction: ltr; text-align: left; }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.thumb { position: relative; width: 96px; height: 72px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); background: #eee center/cover; }
.thumb button { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; line-height: 1; }
.thumb .tag { position: absolute; bottom: 0; right: 0; left: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 10px; padding: 1px 5px; }
.thumb.plan-thumb { width: 72px; height: 54px; background-size: contain; background-repeat: no-repeat; background-color: #fff; }
.upload { display: flex; align-items: center; justify-content: center; height: 72px; width: 96px; border: 1px dashed var(--accent); border-radius: 6px; color: var(--accent); cursor: pointer; font-size: 12px; text-align: center; }
.upload input { display: none; }

.cat-tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.cat-tab { border: 1px solid var(--line); background: var(--field); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.cat-tab.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.cat-tab .cnt { background: var(--accent); color: #fff; border-radius: 999px; min-width: 18px; height: 18px; font-size: 11px; line-height: 18px; text-align: center; padding: 0 4px; font-weight: 700; }
.sel-strip { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -2px 0 12px; }
.sel-strip .lbl { font-size: 12px; color: var(--muted); }
.sel-strip .chip { display: inline-flex; align-items: center; gap: 5px; background: #F6EFE8; border: 1px solid var(--accent); color: var(--ink); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 12.5px; direction: ltr; }
.sel-strip .chip small { color: var(--accent); font-size: 10px; letter-spacing: .05em; }
.sel-strip .chip button { border: 0; background: transparent; color: var(--muted); cursor: pointer; width: 18px; height: 18px; border-radius: 50%; padding: 0; font-size: 11px; }
.sel-strip .chip button:hover { background: var(--accent); color: #fff; }
.col-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; padding: 4px; margin-bottom: 12px; }
.col-pick button { position: relative; border: 2px solid transparent; border-radius: 8px; padding: 0; height: 62px; background: #ddd center/cover; cursor: pointer; overflow: hidden; }
.col-pick button span { position: absolute; bottom: 0; right: 0; left: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; padding: 2px; direction: ltr; }
/* selected models: thick bronze frame, bronze label, big check; once something is selected the rest fade back */
.col-pick button { transition: filter .15s, opacity .15s; }
.col-pick.has-sel button:not(.on) { filter: grayscale(.85) brightness(.8); opacity: .55; }
.col-pick.has-sel button:not(.on):hover { filter: none; opacity: 1; }
.col-pick button.on { border: 3px solid var(--accent); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
.col-pick button.on span { background: var(--accent); font-weight: 700; }
.col-pick button.on::after { content: "✓"; position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; color: #fff; font-size: 14px; font-weight: 700; line-height: 20px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.badge { display: inline-block; margin-right: 6px; padding: 1px 8px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11px; letter-spacing: 0; vertical-align: 1px; }
.rep.models .row { grid-template-columns: 1fr 1.4fr auto; }

.summary { background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.summary div { display: flex; justify-content: space-between; padding: 3px 0; }
.summary .g { font-weight: 700; color: var(--accent); border-top: 1px solid var(--line); margin-top: 4px; padding-top: 7px; }
.warn { color: var(--danger); font-size: 12px; }

.preview { overflow: auto; padding: 28px 24px 80px; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 22px; zoom: var(--z, .7); }
.pages .page { box-shadow: 0 6px 30px rgba(40, 30, 20, .16); }

/* quotes drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; display: none; }
.drawer { position: fixed; top: 0; bottom: 0; right: 0; width: 420px; max-width: 92vw; background: #fff; z-index: 41; transform: translateX(100%); transition: transform .2s; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer.open + .drawer-bg, .drawer-bg.on { display: block; }
.drawer header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer header h3 { margin: 0; font-size: 16px; }
.drawer .search { padding: 12px 18px; border-bottom: 1px solid var(--line); }
.drawer .search input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: var(--field); }
.drawer .list { overflow-y: auto; flex: 1; }
.qrow { padding: 12px 18px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.qrow:hover { background: var(--field); }
.qrow.cur { background: #F6EFE8; }
.qrow .n { font-weight: 600; }
.qrow .s { font-size: 12px; color: var(--muted); }
.qrow .a { grid-row: 1 / 3; grid-column: 2; display: flex; gap: 4px; align-self: center; }
.drawer footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-bg.on { display: flex; }
.login-bg { background: #111; z-index: 60; }
.modal { background: #fff; border-radius: 12px; max-width: 460px; width: 100%; padding: 22px 24px; }
.modal h3 { margin: 0 0 10px; }
.modal ol { padding-right: 18px; line-height: 1.8; margin: 0 0 16px; }
.modal .acts { display: flex; gap: 8px; justify-content: flex-start; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .editor { border-left: 0; border-bottom: 1px solid var(--line); }
  .form { max-height: none; overflow: visible; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; }
  .preview { padding: 16px; }
}

@media print {
  .topbar, .editor, .drawer, .drawer-bg, .modal-bg { display: none !important; }
  body { background: #fff; }
  .layout { display: block; height: auto; }
  .preview { overflow: visible; padding: 0; }
  .pages { zoom: 1 !important; gap: 0; display: block; }
}

/* ?demo&only=N — single page at 1:1 for layout checks */
body.only { background: #fff; }
body.only .topbar, body.only .editor { display: none; }
body.only .layout { display: block; height: auto; }
body.only .preview { padding: 0; overflow: visible; }
body.only .pages { zoom: 1; gap: 0; }
body.only .pages .page { box-shadow: none; }
