:root {
  --ink: #1f2a37; --muted: #6b7785; --line: #e3e8ee; --bg: #f6f7f9; --card: #fff;
  --accent: #e8860c; --accent-ink: #fff; --accent-soft: #fff4e0;
  --ok: #15803d; --ok-soft: #dcfce7; --no: #b42318; --no-soft: #fee4e2; --info: #1d4ed8; --info-soft: #dbeafe;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
a { color: inherit; }
h1 { font-size: 20px; margin: 0; } h2 { font-size: 16px; margin: 0; } h3 { font-size: 14px; margin: 0; }
.muted { color: var(--muted); }
.err { color: var(--no); }

.top { position: sticky; top: 0; z-index: 20; display: flex; gap: 16px; align-items: center; padding: 0 16px; height: 52px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { font-size: 15px; }
#nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; }
#nav a { text-decoration: none; padding: 6px 10px; border-radius: 6px; color: var(--muted); white-space: nowrap; }
#nav a.on { background: var(--accent-soft); color: #8a4b00; font-weight: 600; }
.who { display: flex; gap: 10px; align-items: center; color: var(--muted); white-space: nowrap; }
.link { background: none; border: 0; color: var(--info); cursor: pointer; font: inherit; padding: 0; }

main { max-width: 1240px; margin: 0 auto; padding: 20px 16px 80px; }
.head { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

.btn { font: inherit; font-weight: 600; padding: 7px 13px; border-radius: 7px; border: 1px solid #cfd6de; background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f5f7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(.95); }
.btn.ai { border-color: #c7b8f5; color: #5b3fc4; background: #f6f3ff; }
.btn.ai::before { content: "✦ "; }
.btn.small { padding: 4px 9px; font-size: 13px; font-weight: 500; }
.btn.danger { color: var(--no); border-color: #f1c1bc; }
.btn:disabled { opacity: .55; cursor: wait; }
.icon { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 4px 6px; border-radius: 5px; font-size: 15px; }
.icon:hover { background: #eef1f4; color: var(--ink); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.card + .card { margin-top: 14px; }
.card > h2 { margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }

label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: #3c4855; min-width: 0; }
label.f > small { font-weight: 400; color: var(--muted); }
input, select, textarea { font: inherit; font-size: 14px; padding: 7px 9px; border: 1px solid #cfd6de; border-radius: 7px; background: #fff; color: var(--ink); width: 100%; min-width: 0; }
textarea { resize: vertical; min-height: 70px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid #f5b65c; outline-offset: 0; border-color: #e8a13b; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; font-size: 14px; }
label.check input { width: auto; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.prefix { display: flex; align-items: stretch; }
.prefix span { padding: 7px 9px; background: #f1f3f5; border: 1px solid #cfd6de; border-right: 0; border-radius: 7px 0 0 7px; color: var(--muted); white-space: nowrap; font-weight: 400; max-width: 55%; overflow: hidden; text-overflow: ellipsis; }
.prefix input { border-radius: 0 7px 7px 0; }

table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 9px 12px; background: #fafbfc; border-bottom: 1px solid var(--line); }
.list td { padding: 10px 12px; border-bottom: 1px solid #eef1f4; vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.list tr.click { cursor: pointer; } .list tr.click:hover td { background: #fcfcfd; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: #eef1f4; color: #4b5563; white-space: nowrap; }
.chip.yayinda { background: var(--info-soft); color: var(--info); }
.chip.kabul { background: var(--ok-soft); color: var(--ok); }
.chip.ret, .chip.suresi_doldu { background: var(--no-soft); color: var(--no); }
.chip.fiyat { background: #fff4d6; color: #8a6100; } .chip.yenileme { background: #dce9f7; color: #1d4f91; }

/* teklif editörü */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.side { position: sticky; top: 68px; display: flex; flex-direction: column; gap: 14px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-variant-numeric: tabular-nums; }
.totals .g { font-weight: 800; font-size: 17px; padding-top: 6px; border-top: 1px solid var(--line); }
.linkbox { display: flex; gap: 6px; } .linkbox input { font-size: 13px; }
.dirty { font-size: 12px; color: #b45309; }
.stack { display: flex; flex-direction: column; gap: 8px; }

.item { border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.item + .item { margin-top: 10px; }
.item-head { display: flex; gap: 10px; align-items: center; padding: 10px 12px; cursor: pointer; }
.item-head .no { font-weight: 800; color: #c0c6cd; width: 22px; }
.item-head .t { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-head .p { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.item.open .item-head { border-bottom: 1px solid var(--line); background: #fbfbfc; border-radius: 9px 9px 0 0; }
.item-body { padding: 14px 12px; display: none; }
.item.open .item-body { display: grid; gap: 12px; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 11px; color: var(--muted); border: 1px solid var(--line); padding: 1px 7px; border-radius: 999px; }

.suggest { border: 1px dashed #c7b8f5; background: #faf8ff; border-radius: 9px; padding: 12px; display: grid; gap: 8px; }
.suggest label.check { align-items: flex-start; } .suggest small { display: block; color: var(--muted); font-weight: 400; }

/* pencereler */
dialog { border: 0; border-radius: 12px; padding: 0; width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(17, 24, 39, .4); }
.dlg { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.dlg header { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.dlg .content { padding: 14px 18px; overflow: auto; display: grid; gap: 10px; }
.dlg footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.pick { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 4px; }
.pick p { margin: 0; white-space: pre-wrap; color: #4b5563; font-size: 13px; max-height: 7.5em; overflow: hidden; }
.cat { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-top: 6px; }

.logo-prev { max-height: 56px; max-width: 220px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; padding: 6px; background: #fff; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); background: #fff; border: 1px dashed #d5dbe2; border-radius: 10px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1f2937; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 50; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgba(0, 0, 0, .2); }
#toast.bad { background: var(--no); }

/* giriş */
body.login { display: grid; place-items: center; min-height: 100vh; }
.login-box { width: min(380px, calc(100vw - 32px)); background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 24px; margin: 0; }
.login-box h1 { margin-bottom: 4px; }
.login-box form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.login-box label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }

@media (max-width: 980px) {
  .editor { grid-template-columns: 1fr; }
  .side { position: static; order: -1; }
}
@media (max-width: 640px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; } .span2 { grid-column: auto; }
  .top { height: auto; flex-wrap: wrap; padding: 8px 16px; } #nav { order: 3; flex-basis: 100%; }
  .list .hide-sm { display: none; }
}

/* Bitrix24 arama kutusu */
.picker { position: relative; }
.pick-list { position: absolute; z-index: 30; left: 0; right: 36px; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .12); max-height: 260px; overflow: auto; padding: 4px; }
.pick-row { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; background: none; border: 0; padding: 7px 9px; border-radius: 6px; font: inherit; cursor: pointer; }
button.pick-row:hover { background: var(--accent-soft); }
.pick-row small { color: var(--muted); white-space: nowrap; }

.count { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--no); color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }
.chip.yeni { background: var(--no-soft); color: var(--no); } .chip.hazirlaniyor { background: #fef3c7; color: #92400e; } .chip.gonderildi { background: var(--ok-soft); color: var(--ok); }
.count[hidden] { display: none; }

/* Müşterinin anlaşmaları */
.span3 { grid-column: 1 / -1; }
.deals { display: grid; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: #fbfbfc; }
.deals:empty { display: none; }
.deal-row { display: flex; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 7px; background: #fff; border: 1px solid var(--line); }
.deal-row small { color: var(--muted); }
.deal-row.closed { opacity: .75; }
.deal-row.on { border-color: #86efac; background: #f0fdf4; }

/* Şablonlar */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tpl-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.swatch { display: flex; height: 54px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.swatch span { flex: 1; }
.logo-prev.wide { max-width: 320px; max-height: 70px; }
