:root {
  --brand: #7a1730;
  --brand-600: #651127;
  --brand-50: #fbf1f3;
  --brand-100: #f5dde3;
  --bg: #f6f3f4;
  --card: #ffffff;
  --ink: #23161a;
  --muted: #74676b;
  --line: #ece4e6;
  --ok: #1f7a4d;
  --ok-bg: #e7f5ee;
  --warn: #9a5b00;
  --warn-bg: #fff4dd;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --info: #24539c;
  --info-bg: #e8f0fb;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(35, 22, 26, .05), 0 4px 16px rgba(35, 22, 26, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
small, .muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; word-break: break-all; }
[hidden] { display: none !important; }

/* düğmeler & formlar */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; min-height: 38px; }
.btn:hover { border-color: #d9cdd0; background: #fdfafb; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-600); }
.btn.wa { background: #1c8d4e; border-color: #1c8d4e; color: #fff; }
.btn.wa:hover { background: #167441; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); border-color: #f3c3be; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; min-height: 38px; width: 100%; }
textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
label.f { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* giriş */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 28px; display: grid; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 17px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 16px; }
.err { background: var(--bad-bg); color: var(--bad); padding: 9px 12px; border-radius: 10px; font-size: 14px; }

/* yerleşim */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: #fff; border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 550; }
.nav a:hover { background: var(--bg); }
.nav a.on { background: var(--brand-50); color: var(--brand); }
.nav svg { width: 19px; height: 19px; flex: none; }
.nav .badge { margin-left: auto; }
.side-foot { margin-top: auto; display: grid; gap: 6px; font-size: 13px; }
main { padding: 24px 28px 48px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card > h2 { margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-eq { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi .label { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi .val { font-size: 28px; font-weight: 750; letter-spacing: -.02em; margin-top: 2px; }
.kpi .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.live { background: linear-gradient(135deg, var(--brand), #9b2444); color: #fff; }
.kpi.live .label, .kpi.live .meta { color: rgba(255, 255, 255, .8); }
.pulse { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #4ade80; margin-right: 6px; box-shadow: 0 0 0 0 rgba(74, 222, 128, .7); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }
.seg { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

/* listeler */
.list { display: grid; }
.list .item { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; min-width: 0; }
.list .item:first-child { border-top: 0; }
.list .item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 6px; border-radius: 3px; background: var(--brand-100); overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.feed .item { align-items: flex-start; }
.feed .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; background: #cbbdc1; }
.feed .dot.lead { background: var(--brand); }
.feed .dot.click { background: #1c8d4e; }
.feed .item .t { white-space: normal; }
.feed .new { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--brand-50); } to { background: transparent; } }
.more { margin-top: 8px; }

.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.b-yeni { background: var(--info-bg); color: var(--info); }
.badge.b-iletisime_gecildi, .badge.b-mesaj_gonderildi { background: var(--warn-bg); color: var(--warn); }
.badge.b-teklif_verildi, .badge.b-cevap_verdi, .badge.b-gorusme { background: #f1e8fb; color: #6b3fa0; }
.badge.b-kazanildi, .badge.b-musteri { background: var(--ok-bg); color: var(--ok); }
.badge.b-kaybedildi, .badge.b-ilgilenmiyor, .badge.b-ret { background: var(--bad-bg); color: var(--bad); }
.badge.brand { background: var(--brand); color: #fff; }
.badge.demo { background: #fff4dd; color: #9a5b00; }

/* tablo */
.filters { display: grid; grid-template-columns: 2fr repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #fdfafb; }
.tbl tr.optout td { opacity: .55; }
.tbl .name { font-weight: 650; }
.tbl select { min-height: 32px; padding: 4px 8px; font-size: 13px; width: auto; }
.empty { padding: 32px 12px; text-align: center; color: var(--muted); }

/* kanban */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: #efe9eb; border-radius: 14px; padding: 10px; min-height: 200px; display: flex; flex-direction: column; gap: 8px; }
.kcol.over { outline: 2px dashed var(--brand); }
.kcol h3 { display: flex; justify-content: space-between; padding: 2px 4px 4px; }
.kcard { background: #fff; border-radius: 12px; padding: 11px 12px; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); cursor: grab; display: grid; gap: 4px; font-size: 13.5px; }
.kcard .name { font-weight: 650; }
.kcard select { min-height: 30px; padding: 3px 6px; font-size: 12.5px; }

/* detay */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.timeline { display: grid; gap: 0; }
.timeline .ev { position: relative; padding: 0 0 14px 20px; font-size: 14px; }
.timeline .ev::before { content: ''; position: absolute; left: 4px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.timeline .ev::after { content: ''; position: absolute; left: 7.5px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline .ev:last-child::after { display: none; }
.timeline .ev.note::before { background: #c58b16; }
.timeline .ev.contact::before, .timeline .ev.whatsapp::before { background: #1c8d4e; }
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline .body { white-space: pre-wrap; word-break: break-word; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.note { background: var(--warn-bg); border: 1px solid #f3dca8; color: #6b4300; border-radius: 12px; padding: 12px 14px; font-size: 13.5px; }
.note.info { background: var(--info-bg); border-color: #cfdcf3; color: #1f3f73; }
.counter { display: flex; align-items: center; gap: 12px; }
.counter .big { font-size: 22px; font-weight: 750; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(35, 22, 26, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; padding: 20px; display: grid; gap: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px dashed #d4c3c8; background: var(--brand-50); color: var(--brand); border-radius: 8px; padding: 3px 8px; font-size: 12.5px; font-family: ui-monospace, Menlo, monospace; cursor: pointer; }
.preview { white-space: pre-wrap; background: #e9f7ef; border-radius: 12px; padding: 12px 14px; font-size: 14px; border: 1px solid #cdebd9; }

.toast-wrap { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 11px 15px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: 340px; cursor: pointer; animation: up .25s ease-out; }
.toast.lead { background: var(--brand); }
.toast.bad { background: var(--bad); }
@keyframes up { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.mnav { display: none; }

/* tablet */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-2, .cols-3 { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters .q { grid-column: 1 / -1; }
}
/* telefon */
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  main { padding: 14px 12px 92px; }
  h1 { font-size: 19px; }
  .card { padding: 14px; border-radius: 14px; }
  .grid { gap: 10px; }
  .kpi .val { font-size: 23px; }
  .cols-eq { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv { grid-template-columns: 110px 1fr; }
  .mnav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 40; }
  .mnav a { display: grid; justify-items: center; gap: 2px; font-size: 10.5px; color: var(--muted); text-decoration: none; padding: 4px 0; font-weight: 600; position: relative; }
  .mnav a.on { color: var(--brand); }
  .mnav svg { width: 21px; height: 21px; }
  .mnav .badge { position: absolute; top: -2px; left: 54%; padding: 0 6px; font-size: 10px; }
  .tbl.cards thead { display: none; }
  .tbl.cards, .tbl.cards tbody, .tbl.cards tr, .tbl.cards td { display: block; width: 100%; }
  .tbl.cards tr { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; background: #fff; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
  .tbl.cards td { border: 0; padding: 2px 0; font-size: 13.5px; }
  .tbl.cards td.full { grid-column: 1 / -1; }
  .tbl.cards td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
  .kanban { grid-template-columns: repeat(5, 78vw); scroll-snap-type: x mandatory; }
  .kcol { scroll-snap-align: start; }
  .toast-wrap { left: 12px; right: 12px; bottom: 80px; }
  .modal { padding: 16px; }
}
