:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --border: #e2e6ec;
  --text: #1c2430;
  --muted: #5b6576; /* beyaz ve gri zeminde 4.5:1 üstü */
  --control-border: #8a94a6; /* giriş kutusu kenarı (WCAG 1.4.11: 3:1) */
  --primary: #1f6feb;
  --primary-text: #ffffff;
  --rail: #14213d;
  --rail-text: #b9c3d6;
  --rail-active: #22345c;
  --in-bubble: #ffffff;
  --out-agent: #dcebff;
  --out-bot: #ece7fb;
  --danger: #d1242f;
  --ok: #1a7f37;
  --warn-bg: #fff4e5;
  --warn-text: #8a4b08;
  --note-bg: #eef2f7;
  --tg: #0b7bbf; /* beyaz yazıyla 4.6:1 */
  --wa: #15803d; /* beyaz yazıyla 5:1 */
  --hover: #eef1f5;
  --radius: 10px;
  --primary-fg: #1f6feb; /* mavi yazı/bağlantı rengi (zeminden ayrı) */
  --away: #b45309; /* Molada */
  --note: #eab308; /* ekip notu / uyarı sarısı */
  --note-text: #8a5a00;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --panel: #171b23;
    --border: #2a303b;
    --text: #e5e8ee;
    --muted: #97a0af;
    --control-border: #6b7280;
    --primary: #2563eb; /* beyaz yazıyla 5.2:1 */
    --primary-fg: #60a5fa; /* koyu panelde 6.8:1 */
    --danger: #f85149;
    --ok: #3fb950;
    --away: #f59e0b;
    --note-text: #facc15;
    --rail: #0b1020;
    --rail-active: #1c2740;
    --in-bubble: #212733;
    --out-agent: #1d3557;
    --out-bot: #322a55;
    --warn-bg: #3a2512;
    --warn-text: #fdba74;
    --note-bg: #1f2530;
    --hover: #1f2430;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 8px; }
h2 { font-size: 16px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
code { background: var(--hover); padding: 1px 4px; border-radius: 4px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1.2em; }
.ok { color: var(--ok); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
#integration-sections label > span:first-child { display: block; margin-bottom: 4px; }
#integration-sections label .btn { margin-top: 4px; }

input, select, textarea, button { font: inherit; color: inherit; }
/* Tutarlı odak görünümü (klavyeyle gezinme ve yazma alanları) */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.nowrap { white-space: nowrap; }
input, select, textarea {
  background: var(--panel);
  border: 1px solid var(--control-border);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
input[type=checkbox] { width: auto; }
textarea { resize: vertical; }
label { display: block; margin: 8px 0; }
label.check { display: flex; gap: 8px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--panel);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.link-btn { border: 0; background: none; padding: 0; color: var(--primary-fg); cursor: pointer; text-align: left; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > input, .row.wrap > select { flex: 1 1 160px; width: auto; }
.row > input:not([type=file]) { flex: 1; }
.row > select { width: auto; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; text-align: center; line-height: 18px; }

/* Giriş */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--rail), #24407a); }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-card label { text-align: left; }
.login-card .btn { width: 100%; margin-top: 8px; }
.login-logo, .rail-logo { display: block; width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 14px; }

/* Uygulama iskeleti: sol menü + içerik */
.app { height: 100%; display: grid; grid-template-columns: 76px 1fr; }
.rail { background: var(--rail); color: var(--rail-text); display: flex; flex-direction: column; align-items: stretch; padding: 12px 6px; gap: 4px; min-height: 0; overflow-y: auto; }
.rail-logo { width: 40px; height: 40px; margin-bottom: 8px; }
.rail-btn {
  position: relative; border: 0; background: transparent; color: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px; border-radius: 10px; font-size: 10.5px;
}
.rail-btn span { white-space: nowrap; letter-spacing: -.01em; }
/* Kısa ekranlarda menü kaydırmasın diye sıkılaştır */
@media (min-width: 701px) and (max-height: 860px) {
  .rail { gap: 1px; padding-top: 8px; }
  .rail-logo { width: 34px; height: 34px; margin-bottom: 4px; }
  .rail-btn { padding: 5px 2px; gap: 2px; }
  .rail-btn svg { width: 20px; height: 20px; }
}
.rail-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rail-btn:hover { background: var(--rail-active); color: #fff; }
.rail-btn.active { background: var(--rail-active); color: #fff; box-shadow: inset 3px 0 0 var(--primary); }
.rail-btn .badge { position: absolute; top: 4px; right: 10px; }
.rail-bottom { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.08); }
.rail-bottom .btn { color: var(--rail-text); }
.me { font-size: 10px; text-align: center; word-break: break-word; }
/* Çevrimiçi durum düğmesi (sohbet listesinin başlığında) */
.presence {
  display: inline-flex; align-items: center; gap: 8px; margin: 0; cursor: pointer; user-select: none;
  padding: 4px 12px 4px 6px; border-radius: 16px; border: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; transition: all .15s;
}
.presence:hover { border-color: var(--muted); }
.presence input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.presence:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.presence .dot { width: 30px; height: 16px; border-radius: 8px; background: #8691a3; position: relative; transition: background .15s; }
.presence .dot::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: transform .15s; }
.presence.on { border-color: var(--ok); color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.presence.on .dot { background: var(--ok); }
.presence.on .dot::after { transform: translateX(14px); }
.pane-chips { padding: 0 12px 8px; }

/* Durum düğmesi ve menüsü (Çevrimiçi / Molada / Çevrimdışı) */
.presence-wrap { position: relative; }
.presence { background: none; font: inherit; font-size: 12px; font-weight: 600; }
.presence .chev { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.presence.online { border-color: var(--ok); color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.presence.away { border-color: var(--away); color: var(--away); background: color-mix(in srgb, var(--away) 10%, transparent); }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #8691a3; flex-shrink: 0; }
.status-dot.online, .presence.online .status-dot { background: var(--ok); }
.status-dot.away, .presence.away .status-dot { background: var(--away); }
.pop-menu.presence-menu { position: absolute; left: 0; right: auto; top: calc(100% + 6px); min-width: 280px; }
.status-item { display: flex; gap: 10px; align-items: flex-start; }
.status-item .status-dot { margin-top: 5px; }
.status-item > span:last-child { display: grid; }
.away-banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 0 10px 8px; padding: 8px 10px; border-radius: 10px; font-size: 12px; background: color-mix(in srgb, var(--away) 14%, transparent); border: 1px solid color-mix(in srgb, var(--away) 40%, transparent); }

/* Bildirimler */
.notif-panel {
  position: fixed; left: 84px; bottom: 16px; width: 360px; max-height: min(70vh, 560px); z-index: 20;
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.28); overflow: hidden;
}
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.notif-list { list-style: none; margin: 0; padding: 4px; overflow-y: auto; }
.notif-item { display: grid; gap: 2px; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.notif-item:hover { background: var(--hover); }
.notif-item.unread { background: color-mix(in srgb, var(--primary) 9%, transparent); }
.notif-item.unread b::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); margin-right: 6px; vertical-align: middle; }
.notif-empty { padding: 18px; text-align: center; }
.notif-banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 0 10px 8px; padding: 8px 10px; border-radius: 10px; font-size: 12px; background: color-mix(in srgb, var(--primary) 12%, transparent); border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent); }
.notif-banner .row { margin: 0; }
/* Profil düğmesi (sol alt) ve açılır menüler */
.me-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none; color: var(--rail-text); cursor: pointer; padding: 6px 2px; border-radius: 10px; width: 100%; }
.me-btn:hover { background: var(--rail-active); color: #fff; }
.me-avatar { width: 34px; height: 34px; font-size: 12px; background: #3a4a6b; box-shadow: 0 0 0 2px rgba(255,255,255,.12); }
.pop-menu { position: fixed; z-index: 30; min-width: 240px; padding: 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.28); display: grid; gap: 2px; }
.me-menu { left: 84px; bottom: 16px; }
.me-menu-head { display: flex; gap: 10px; align-items: center; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-item { text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.menu-item:hover { background: var(--hover); }
.menu-item.danger { color: var(--danger); }
/* Fotoğraflı avatar */
.avatar.has-img { background: none; overflow: visible; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; background: var(--primary); }
.avatar.xs { display: inline-grid; width: 16px; height: 16px; font-size: 8px; vertical-align: -3px; margin-right: 5px; background: #64748b; }
.card-pad { padding: 14px 16px 0; }

/* İstatistikler */
.range-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.range-bar input[type=date] { width: auto; padding: 6px 8px; }
.seg { border: 1px solid var(--border); background: var(--panel); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.seg.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 26px; font-weight: 700; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); }
/* Çubuk grafik: ince çubuklar, üstü 4px yuvarlak, aralarında boşluk, belirgin olmayan ızgara */
.bar-chart { position: relative; height: 240px; padding: 8px 0 26px 40px; }
.bc-grid { position: absolute; inset: 8px 0 26px 40px; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.bc-line { position: relative; border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent); height: 0; }
.bc-tick { position: absolute; right: calc(100% + 8px); top: -8px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bc-bars { position: absolute; inset: 8px 0 0 40px; display: flex; align-items: stretch; gap: 2px; }
.bc-col { flex: 1; position: relative; display: flex; flex-direction: column; justify-content: flex-end; padding-bottom: 26px; cursor: default; border-radius: 6px; outline-offset: 0; }
.bc-col.hover { background: color-mix(in srgb, var(--primary) 7%, transparent); }
.bc-bar { width: min(60%, 28px); margin: 0 auto; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.bc-bar.zero { background: var(--border); }
.bc-x { position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--muted); white-space: nowrap; }
.bc-x.hide { visibility: hidden; }
.bc-tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 10px; border-radius: 8px; font-size: 12px; display: grid; gap: 2px; pointer-events: none; z-index: 2; white-space: nowrap; }
.bc-tip .muted { color: inherit; opacity: .75; }
/* Temsilci tablosu: geniş ekranda satır, dar ekranda kart */
.agent-stats { display: grid; }
.as-row { display: grid; grid-template-columns: minmax(180px, 1.6fr) repeat(8, minmax(70px, 1fr)); align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); }
.as-head { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; border-top: 0; }
.as-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.as-name b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-cell { font-variant-numeric: tabular-nums; text-align: right; }
.as-head .as-cell { text-align: right; }
.agent-stats .empty { padding: 24px; }
@media (max-width: 1100px) {
  .as-head { display: none; }
  .as-row { grid-template-columns: repeat(4, 1fr); }
  .as-name { grid-column: 1 / -1; }
  .as-cell { text-align: left; display: grid; gap: 2px; }
  .as-cell::before { content: attr(data-label); font-size: 11px; color: var(--muted); }
}

/* Yazma alanı: Yanıt / Ekip notu sekmeleri ve hazır yanıt listesi */
#composer.composer { flex-direction: column; align-items: stretch; gap: 6px; }
#composer > .composer-tabs, #composer > .composer-row { width: 100%; }
.composer-tabs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.ctab { border: 1px solid transparent; background: none; padding: 4px 10px; border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); }
.ctab.active { background: var(--hover); color: var(--text); border-color: var(--border); }
.ctab[data-mode="note"].active { background: color-mix(in srgb, var(--note) 18%, transparent); border-color: color-mix(in srgb, var(--note) 45%, transparent); color: var(--text); }
.ctab:disabled { opacity: .4; cursor: not-allowed; }
.composer-hint { margin-left: auto; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer-input { position: relative; flex: 1; display: flex; }
.composer.note-mode textarea { background: color-mix(in srgb, var(--note) 10%, var(--panel)); border-color: color-mix(in srgb, var(--note) 45%, var(--border)); }
.canned-pop { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 10; list-style: none; margin: 0; padding: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 28px rgba(0,0,0,.25); max-height: 300px; overflow-y: auto; }
.canned-item { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.canned-item b { color: var(--primary-fg); }
.canned-item .canned-prev { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.canned-item.active, .canned-item:hover { background: var(--hover); }
.canned-empty { padding: 10px; }
.canned-list { display: grid; gap: 6px; margin-bottom: 12px; }
.canned-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.canned-body { min-width: 0; }
.canned-body .canned-prev { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60ch; }
.canned-form { display: grid; gap: 12px; }
.canned-form .row { margin: 0; }
.canned-form label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
/* Hazır yanıtlar sayfası: solda liste, sağda düzenleyici (dar ekranda alt alta) */
.canned-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.canned-layout.editing { grid-template-columns: minmax(0, 1.3fr) minmax(320px, 1fr); }
@media (max-width: 900px) { .canned-layout.editing { grid-template-columns: minmax(0, 1fr); } }
.canned-list-card .row { margin-bottom: 12px; }
.canned-list-card input[type="search"] { flex: 1; }
.canned-list-card .canned-list { margin: 0; }
.canned-row { cursor: default; }
.canned-row.selected { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); }
.canned-row .canned-body code { color: var(--primary-fg); font-weight: 700; }
.canned-body .canned-prev { max-width: none; }
.canned-list > *, .canned-row > .canned-body { min-width: 0; }
.canned-row > .canned-body { flex: 1; }
.canned-meta { font-size: 11px; margin-top: 2px; }
.canned-editor { position: sticky; top: 0; }
.shortcut-input { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; background: var(--bg, transparent); overflow: hidden; }
.shortcut-input span { padding: 0 4px 0 10px; color: var(--primary-fg); font-weight: 700; }
.shortcut-input input { border: 0; flex: 1; background: transparent; }
.shortcut-input input:focus { outline: none; }
.shortcut-input:focus-within { border-color: var(--primary); }
.canned-preview { display: grid; gap: 4px; padding: 10px 12px; border-radius: 10px; background: var(--hover); }
#canned-preview-text { white-space: pre-wrap; font-size: 13px; min-height: 1.4em; }
.notice { padding: 10px 14px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--note) 45%, transparent); background: color-mix(in srgb, var(--note) 12%, transparent); margin: 0 0 14px; }
/* Ekip içi not */
.note-msg { align-self: center; width: min(640px, 92%); box-sizing: border-box; margin: 2px auto; padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, var(--note) 12%, var(--panel)); border: 1px dashed color-mix(in srgb, var(--note) 55%, transparent); }
.note-head { font-size: 11px; display: flex; align-items: center; gap: 2px; margin-bottom: 2px; }
/* Bekleme süresi ve WhatsApp penceresi */
.sla { font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 8px; white-space: nowrap; background: var(--hover); color: var(--muted); }
.sla.warn { background: color-mix(in srgb, var(--note) 22%, transparent); color: var(--note-text); }
.sla.alert { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.chat-timers { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.chat-timers:empty { display: none; }
.presence-dot.away { background: var(--away); }

/* Sayfa içi sekme menüsü */
.subnav { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--border); margin: 4px 0 18px; }
.subnav-btn { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 8px 8px 0 0; }
.subnav-btn:hover { color: var(--text); background: var(--hover); }
.subnav-btn.active { color: var(--primary-fg); border-bottom-color: var(--primary-fg); }
.tab-hidden { display: none !important; }

/* Gizli değer alanı (token/anahtar): şifre alanı değil, yazılanlar noktalarla gizlenir (tarayıcı şifre doldurmasın) */
.secret-input { -webkit-text-security: disc; text-security: disc; font-family: ui-monospace, Consolas, monospace; }

/* Kanal profil kartları */
.profile-card { display: grid; gap: 4px; align-content: start; }
.profile-card > .btn { justify-self: start; margin-top: 6px; }
.photo-pick { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 4px 14px; align-items: center; margin: 6px 0 4px; }
.photo-prev { grid-row: span 2; width: 72px; height: 72px; border-radius: 50%; border: 1px dashed var(--border); display: grid; place-items: center; font-size: 11px; color: var(--muted); overflow: hidden; }
.photo-prev img { width: 100%; height: 100%; object-fit: cover; }
.photo-pick .btn { justify-self: start; }

/* Uygulama sayfası */
.apps-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.app-card { display: grid; gap: 10px; align-content: start; }
.app-card h2 { margin: 0; }
.app-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; color: #fff; }
.app-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.app-icon.win { background: #0b6bcb; }
.app-icon.win svg { fill: currentColor; stroke: none; }
.app-icon.web { background: #475569; }
.app-icon.phone { background: #16a34a; }
.download-btn { justify-self: start; }
.steps { margin: 0; padding-left: 18px; display: grid; gap: 4px; color: var(--muted); }
.addr-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.addr-row code { font-size: 13px; padding: 6px 8px; }
.sub-h { margin-top: 18px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); }
@media (max-width: 760px) {
  .notif-panel { left: 8px; right: 8px; bottom: 72px; width: auto; }
}

.view { min-height: 0; min-width: 0; }

/* Gelen kutusu: liste | sohbet | bilgi */
.inbox { display: grid; grid-template-columns: 320px minmax(0, 1fr) 290px; height: 100%; }
.inbox:has(#info-pane[hidden]) { grid-template-columns: 320px minmax(0, 1fr); }
.inbox > * { min-width: 0; } /* uzun önizleme metinleri sütunu ekrandan taşırmasın */
.conv-pane { border-right: 1px solid var(--border); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 6px; }
.pane-head h2 { margin: 0; font-size: 17px; }
.chips { display: flex; gap: 4px; }
.chip { font-size: 10px; padding: 1px 7px; border-radius: 10px; border: 1px solid var(--border); }
.chip.on { border-color: var(--ok); color: var(--ok); }
.chip.off { color: var(--muted); }
.boxes { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--border); }
.box-btn { flex: 1; border: 0; background: none; padding: 8px 4px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; font-size: 13px; }
.box-btn.active { color: var(--primary-fg); border-bottom-color: var(--primary-fg); }
.box-btn .count { font-weight: 400; font-size: 11px; }
.conv-tools { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.conv-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.conv:hover { background: var(--hover); }
.conv.active { background: var(--hover); box-shadow: inset 3px 0 0 var(--primary); }
.conv.unread .title { font-weight: 700; }
.conv-body { flex: 1; min-width: 0; }
.conv-top, .conv-bottom { display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.conv .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .time { color: var(--muted); font-size: 11px; flex-shrink: 0; }
.conv .preview { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .flags { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; color: #fff; font-size: 13px; font-weight: 700; background: #7a8699; position: relative; }
.avatar.telegram { background: var(--tg); }
.avatar.whatsapp { background: var(--wa); }
/* Kanal gösterimi (WhatsApp / Telegram) */
.ch-tag { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; font-weight: 700; padding: 1px 6px 1px 4px; border-radius: 8px; color: #fff; flex-shrink: 0; vertical-align: middle; }
.ch-tag svg { width: 11px; height: 11px; fill: currentColor; }
.ch-tag.whatsapp { background: var(--wa); }
.ch-tag.telegram { background: var(--tg); }
.chat-head .ch-tag { font-size: 11px; padding: 2px 8px 2px 5px; }
.chat-head .ch-tag svg { width: 13px; height: 13px; }
.ch-corner { position: absolute; right: -3px; bottom: -3px; width: 17px; height: 17px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--panel); }
.ch-corner svg { width: 10px; height: 10px; fill: #fff; }
.ch-corner.whatsapp { background: var(--wa); }
.ch-corner.telegram { background: var(--tg); }
.title-wrap { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ch-filters { display: flex; gap: 4px; margin-top: 6px; }
.ch-filter { flex: 1; border: 1px solid var(--border); background: none; border-radius: 12px; padding: 3px 6px; font-size: 11px; cursor: pointer; color: var(--muted); }
.ch-filter.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.ch-filter.whatsapp.active { background: var(--wa); border-color: var(--wa); }
.ch-filter.telegram.active { background: var(--tg); border-color: var(--tg); }
.tag { font-size: 10px; padding: 1px 6px; border-radius: 8px; background: var(--hover); color: var(--muted); white-space: nowrap; }
.tag.human { background: var(--warn-bg); color: var(--warn-text); }
.tag.mode { background: var(--out-bot); color: var(--text); }
.conv-empty { padding: 24px; text-align: center; color: var(--muted); }
.team-strip { border-top: 1px solid var(--border); padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: 12px; }
.team-strip > div { width: 100%; }
.person { display: inline-flex; align-items: center; gap: 4px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); }

.chat-pane { display: flex; min-height: 0; min-width: 0; }
.empty { margin: auto; text-align: center; color: var(--muted); padding: 24px; }
.empty-icon { font-size: 40px; opacity: .5; }
.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--border); }
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .name { font-weight: 600; }
.chat-head .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
#btn-info { display: none; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: min(72%, 560px); padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; border: 1px solid var(--border); }
.msg.in { align-self: flex-start; background: var(--in-bubble); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--out-agent); border-bottom-right-radius: 4px; }
.msg.out.bot { background: var(--out-bot); }
.msg { position: relative; }
.msg-text { white-space: pre-wrap; }
/* Düzenle düğmesi: mesajın üzerine gelince görünür (dokunmatik ekranda hep görünür) */
.msg-edit {
  position: absolute; top: -10px; left: -10px; border: 1px solid var(--border); background: var(--panel); color: var(--text);
  font-size: 11px; padding: 2px 8px; border-radius: 10px; cursor: pointer; opacity: 0; transition: opacity .12s;
}
.msg:hover .msg-edit, .msg-edit:focus-visible { opacity: 1; }
@media (hover: none) { .msg-edit { opacity: .85; } }
.edit-box { display: grid; gap: 6px; min-width: min(420px, 70vw); }
.edit-box textarea { background: var(--panel); }
.edit-box .row { margin: 0; justify-content: flex-end; }
.msg .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.msg.failed { border-color: var(--danger); }
.msg.failed .meta { color: var(--danger); }
.day { align-self: center; font-size: 11px; color: var(--muted); margin: 8px 0; }
.event { align-self: center; font-size: 11px; color: var(--muted); background: var(--note-bg); padding: 3px 10px; border-radius: 10px; text-align: center; }
.warning { background: var(--warn-bg); color: var(--warn-text); padding: 8px 16px; font-size: 13px; }
.note { background: var(--note-bg); color: var(--muted); padding: 10px 16px; font-size: 13px; border-top: 1px solid var(--border); }
.composer { display: flex; gap: 8px; padding: 10px 16px; background: var(--panel); border-top: 1px solid var(--border); align-items: flex-end; }
.composer textarea { flex: 1; resize: none; min-height: 42px; max-height: 160px; line-height: 1.4; }

.info-pane { border-left: 1px solid var(--border); background: var(--panel); overflow-y: auto; min-height: 0; }
.info-section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.info-list { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0; font-size: 13px; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; word-break: break-word; }
.info-section .row select { flex: 1; width: auto; min-width: 0; }
.related { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 13px; }

/* Sayfalar */
/* Sayfalar ekranın tamamını kullanır; kartlar geniş ekranda yan yana dizilir */
.page { overflow-y: auto; padding: 24px 28px; height: 100%; }
.page-title { font-size: 22px; margin-bottom: 4px; }
.page > .page-title { margin-bottom: 16px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; align-items: start; }
.card-grid > .card { margin-bottom: 0; }
.card.flush { padding: 0; overflow: hidden; }

/* Ekip & yetkiler: solda kişiler, sağda ayrıntı */
.team-layout { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.people { list-style: none; margin: 0; padding: 6px; display: grid; gap: 2px; }
.person-row { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.person-row:hover { background: var(--hover); }
.person-row.active { background: color-mix(in srgb, var(--primary) 14%, transparent); box-shadow: inset 3px 0 0 var(--primary); }
.person-body { flex: 1; min-width: 0; }
.person-top { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.person-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 10px; letter-spacing: .02em; white-space: nowrap; }
.role-badge.role-admin, .avatar.role-admin { background: #7c3aed; color: #fff; }
.role-badge.role-supervisor, .avatar.role-supervisor { background: #0e7490; color: #fff; }
.role-badge.role-agent, .avatar.role-agent { background: #475569; color: #fff; }
.presence-dot { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: #8691a3; border: 2px solid var(--panel); }
.presence-dot.on { background: var(--ok); }
.new-user { padding: 14px; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.new-user h3 { margin: 0; }
.team-detail { padding: 0; }
.team-detail .empty { padding: 48px; }
.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.detail-who { display: flex; gap: 12px; align-items: center; }
.detail-who .avatar { width: 44px; height: 44px; font-size: 15px; }
.detail-who h2 { margin: 0; font-size: 18px; }
.detail-section { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.detail-section:last-child { border-bottom: 0; }
.role-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.role-card { text-align: left; display: grid; gap: 4px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); cursor: pointer; }
.role-card:hover:not(:disabled) { border-color: var(--muted); }
.role-card.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); }
.role-card:disabled { opacity: .5; cursor: default; }
.perm-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.perm-group { border: 1px solid var(--border); border-radius: 10px; padding: 6px 14px; }
.perm-group h4 { margin: 8px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; margin: 0; border-top: 1px solid var(--border); cursor: pointer; }
.perm-group h4 + .perm-row { border-top: 0; }
.perm-text { display: grid; gap: 2px; }
.perm-title { font-weight: 600; }
/* Açma/kapama anahtarı */
.switch-ctl { position: relative; flex-shrink: 0; width: 38px; height: 22px; }
.switch-ctl input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch-ctl .track { position: absolute; inset: 0; border-radius: 11px; background: #8691a3; transition: background .15s; }
.switch-ctl .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch-ctl input:checked + .track { background: var(--ok); }
.switch-ctl input:checked + .track::after { transform: translateX(16px); }
.switch-ctl input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch-ctl input:disabled + .track { opacity: .55; }
.switch-ctl input:disabled { cursor: default; }
@media (max-width: 900px) {
  .team-layout { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
}
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table td.link { max-width: 220px; }
.table .perm-col { text-align: center; }
.links .row { flex-wrap: wrap; }
.days { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 4px 0 8px; }
.days .day { margin: 0; }
.row.wrap > label { flex: 1 1 140px; margin: 0; }
pre.raw { background: var(--hover); padding: 10px; border-radius: 8px; max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.test-result { margin-top: 12px; padding: 12px; border-radius: 8px; background: var(--hover); white-space: pre-wrap; }
.status-detail { display: grid; gap: 6px; }
.status-detail div { display: flex; gap: 8px; }
.status-detail b { min-width: 120px; }

.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 8px; z-index: 10; max-width: calc(100% - 32px); }

.mobile-only { display: none; }

/* Orta ekran: bilgi paneli düğmeyle açılır */
@media (max-width: 1200px) {
  .inbox, .inbox:has(#info-pane[hidden]) { grid-template-columns: 300px 1fr; position: relative; }
  #btn-info { display: inline-flex; }
  .info-pane { display: none; }
  .inbox.info-open .info-pane:not([hidden]) { display: block; position: absolute; right: 0; top: 0; bottom: 0; width: 290px; z-index: 5; box-shadow: -6px 0 18px rgba(0,0,0,.15); }
}

/* Telefon */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail { order: 2; flex-direction: row; overflow: visible; padding: 4px; border-top: 1px solid rgba(255,255,255,.08); }
  /* Alt çubukta yalnızca ana düğmeler; "Menü" açılınca diğerleri çubuğun üstünde 4'lü ızgara olur (yana kaydırma yok) */
  .rail-btn[data-view]:not([data-mobile-main]) { display: none; }
  .rail.more-open { flex-wrap: wrap; row-gap: 4px; }
  .rail.more-open > [data-mobile-main], .rail.more-open > .rail-bottom { order: 1; }
  .rail.more-open::before { content: ''; flex-basis: 100%; height: 0; order: 0; }
  .rail.more-open .rail-btn[data-view]:not([data-mobile-main]):not([hidden]) { display: flex; order: -1; flex: 0 0 calc(25% - 3px); padding: 10px 2px; }
  .rail-more[aria-expanded="true"], .rail-more.has-active { background: var(--rail-active); color: #fff; }
  .composer-hint { display: none; }
  .table-wrap:has(.table.stack) { overflow: visible; }
  .table.stack, .table.stack tbody { display: block; width: 100%; }
  .table.stack thead { display: none; }
  .table.stack tr { display: block; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; }
  .table.stack td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; padding: 4px 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }
  .table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: 0 0 auto; }
  .table.stack td:first-child { font-weight: 600; }
  .table.stack td > :last-child { margin-left: auto; }
  .canned-row { flex-wrap: wrap; }
  .canned-row > .row { width: 100%; justify-content: flex-end; }
  .rail-logo, .rail-bottom .me { display: none; }
  .me-btn { padding: 4px 6px; }
  .me-menu { left: 8px; right: 8px; bottom: 72px; }
  .bar-chart { padding-left: 32px; }
  .bc-grid, .bc-bars { left: 32px; }
  .rail-btn { flex: 1 0 50px; font-size: 10px; padding: 6px 2px; }
  .rail-btn svg { width: 20px; height: 20px; }
  .pane-head h2 { font-size: 16px; }
  .rail-bottom { margin: 0; flex-direction: row; border-top: 0; padding: 0 4px; }
  .inbox, .inbox:has(#info-pane[hidden]) { grid-template-columns: 1fr; }
  .inbox.chat-open .conv-pane { display: none; }
  .inbox:not(.chat-open) .chat-pane { display: none; }
  .inbox.info-open .info-pane:not([hidden]) { width: 100%; }
  .mobile-only { display: inline-flex; }
  .msg { max-width: 88%; }
  .page { padding: 12px; }
  .chat-head { padding: 8px; gap: 8px; }
}

/* Klavye kısayolları penceresi */
.shortcuts-dialog { border: 1px solid var(--border); border-radius: 14px; background: var(--panel); color: var(--text); padding: 20px 24px; width: min(440px, calc(100% - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.shortcuts-dialog::backdrop { background: rgba(0,0,0,.45); }
.shortcuts-dialog h2 { margin: 0 0 12px; font-size: 17px; }
.shortcut-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0 0 16px; }
.shortcut-list dt { font-family: ui-monospace, monospace; font-size: 12px; background: var(--hover); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; white-space: nowrap; align-self: start; }
.shortcut-list dd { margin: 0; font-size: 13px; }
/* Hareket azaltma tercihi */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
/* Dokunmatik ekranda küçük düğmeler parmakla rahat basılabilsin (WCAG 2.5.8) */
@media (pointer: coarse) { .btn.small, .ctab, .ch-filter, .msg-edit, .subnav-btn, .box-btn { min-height: 40px; } }
/* Klavyeyle gezinirken odak görünür olsun */
:focus-visible { outline: 2px solid var(--primary-fg); outline-offset: 2px; }
.conv:focus-visible { outline-offset: -2px; }
