:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --top: #111827;
  --top-text: #ffffff;
  --accent: #2563eb;
  --in: #ffffff;
  --out: #dcfce7;
  --new-bg: #dbeafe;   --new: #1d4ed8;
  --wait-bg: #ffedd5;  --wait: #c2410c;
  --done-bg: #dcfce7;  --done: #15803d;
  --late-bg: #fee2e2;  --late: #dc2626;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17;
    --card: #161b26;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --line: #273042;
    --top: #000000;
    --accent: #60a5fa;
    --in: #1f2633;
    --out: #14432a;
    --new-bg: #1e3a8a;   --new: #bfdbfe;
    --wait-bg: #7c2d12;  --wait: #fed7aa;
    --done-bg: #14532d;  --done: #bbf7d0;
    --late-bg: #7f1d1d;  --late: #fecaca;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--top); color: var(--top-text);
}
.top h1 { margin: 0; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .back { color: var(--top-text); text-decoration: none; font-size: 32px; line-height: 1; padding: 0 8px 4px 0; }

main { max-width: 720px; margin: 0 auto; padding-bottom: 32px; }
.empty, .soon { color: var(--muted); text-align: center; padding: 24px 16px; }

/* Liste ekranı */
.list { list-style: none; margin: 0; padding: 0; background: var(--card); }
.list li + li { border-top: 1px solid var(--line); }
.row {
  display: flex; gap: 12px; align-items: center;
  padding: 14px 16px; color: inherit; text-decoration: none;
  min-height: 64px;
}
.row:active { background: var(--bg); }
.flag { font-size: 26px; line-height: 1; flex: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.line1, .line2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.name, .detail { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line1 time { color: var(--muted); font-size: 13px; flex: none; }
.detail { color: var(--muted); font-size: 14px; }
.badge { flex: none; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.badge.new { background: var(--new-bg); color: var(--new); }
.badge.waiting { background: var(--wait-bg); color: var(--wait); }
.badge.done { background: var(--done-bg); color: var(--done); }
.badge.handled { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

/* Bölüm sekmeleri (yatay kaydırılabilir) */
.tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px; background: var(--card);
  border-bottom: 1px solid var(--line); scrollbar-width: none; position: sticky; top: 52px; z-index: 5;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; display: inline-flex; align-items: center; gap: 4px; min-height: 36px;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--text); text-decoration: none; font-size: 14px; white-space: nowrap;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab .count { background: var(--late); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 12px; }
.row.unread .name { font-weight: 800; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }
/* Bölümler ekranı ve "Bölüm değiştir" */
.card h2 { font-size: 16px; margin: 12px 0 8px; }
.hint, .muted { color: var(--muted); font-size: 14px; }
p.hint { margin: 12px 16px; }
.card p.hint { margin: 0 0 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; padding: 8px 0 12px; }
.stack .primary, .stack .secondary { margin: 0; }
.row2 { display: flex; gap: 8px; }
.icon-input { width: 56px !important; flex: none; text-align: center; }
select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-height: 44px;
}
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; overflow-wrap: anywhere; }
.check input { margin-top: 3px; flex: none; }
.cat-edit { border-top: 1px solid var(--line); }
.cat-edit summary, .move summary { padding: 12px 0; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.cat-edit summary small { color: var(--muted); }
.new-cat { border-top: 1px solid var(--line); margin-top: 4px; }
.new-cat label:first-of-type { font-weight: 600; }
.danger { color: var(--late) !important; }
.rules { list-style: none; margin: 0; padding: 0; }
.rules li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.rules li code { overflow-wrap: anywhere; }
.rules li span { flex: 1; color: var(--muted); }
.move summary { justify-content: flex-start; }
.small-link { text-align: center; padding: 4px; }
.tab.settings { font-size: 16px; }

/* Giriş */
.login { max-width: 420px; margin: 32px auto; padding: 16px 20px; }
.login-logo { display: flex; justify-content: center; padding: 8px 0 16px; }
.login-logo img { border-radius: 10px; }
input[type="password"] {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-height: 48px;
}
.top .logout { margin-left: auto; color: var(--top-text); opacity: .7; text-decoration: none; font-size: 14px; }

.handled-form { margin: 0 16px; }
.handled-form button { margin: 0 0 4px; min-height: 40px; }
/* Ekler */
.atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.att-img img { display: block; width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.att-file {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text); text-decoration: none; max-width: 100%;
}
.att-file .att-name { overflow-wrap: anywhere; }
.att-file small { color: var(--muted); white-space: nowrap; }
.attach { padding-top: 8px; }
.attach-buttons { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
label.pick { display: inline-flex; align-items: center; cursor: pointer; min-height: 40px; }
.cards { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.acard {
  display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line); font-size: 14px;
}
.acard img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; flex: none; }
.acard-icon { width: 48px; text-align: center; font-size: 26px; flex: none; }
.acard-info { flex: 1; overflow-wrap: anywhere; }
.acard-del {
  flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: var(--late-bg); color: var(--late); font-size: 20px; line-height: 1;
}
.acard.loading { color: var(--muted); padding: 12px; }
.preview-atts { margin-top: 12px; }
.preview-atts ul { margin: 4px 0 0; padding-left: 0; list-style: none; font-size: 14px; }
.preview-atts li { padding: 2px 0; overflow-wrap: anywhere; }
.preview-atts small { color: var(--muted); }
.att { font-size: 14px; margin-top: 6px; overflow-wrap: anywhere; }
.att small { color: var(--muted); }

/* Konuşma ekranı */
.card { background: var(--card); margin: 12px 16px; border-radius: 12px; padding: 4px 16px; }
.info div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; text-align: right; }
.info div:first-child { border-top: 0; }
.info div > span:first-child { color: var(--muted); text-align: left; flex: none; }
.info .actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.info .wa { color: #16a34a; font-weight: 600; }

.chat { list-style: none; margin: 0; padding: 0 16px; display: flex; flex-direction: column; gap: 10px; }
.bubble, .card, #son { scroll-margin-top: 72px; }
.bubble {
  max-width: 85%; padding: 10px 12px; border-radius: 14px;
  box-shadow: 0 1px 1px rgba(0,0,0,.08); overflow-wrap: anywhere;
}
.bubble.in { align-self: flex-start; background: var(--in); border-top-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--out); border-top-right-radius: 4px; }
.bubble .meta { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.bubble .foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 4px; }
.bubble time { font-size: 12px; color: var(--muted); }

/* Çeviri ve yanıt */
.bubble .tr {
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line);
  color: var(--muted); font-size: 15px;
}
form.inline { margin-top: 6px; }
button { font: inherit; cursor: pointer; }
button:disabled { opacity: .6; cursor: progress; }
button.small {
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  border-radius: 999px; padding: 4px 12px; font-size: 14px; min-height: 32px;
}
.compose label, .preview label { display: block; font-weight: 600; margin: 12px 0 6px; }
.compose label small, .preview label small { font-weight: 400; color: var(--muted); }
textarea, input[type="text"] {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px; resize: vertical;
}
textarea:focus, input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.primary, .send, .secondary {
  width: 100%; min-height: 48px; border-radius: 10px; border: 0; font-weight: 600; margin: 10px 0 12px;
}
.primary { background: var(--accent); color: #fff; }
.send { background: #16a34a; color: #fff; }
.secondary { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
.buttons { display: flex; gap: 10px; }
.buttons button { flex: 1; }
.lang-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-top: 12px; }
.lang-row span { color: var(--muted); margin-right: 4px; }
.lang {
  border: 1px solid var(--line); background: transparent; color: var(--text);
  border-radius: 999px; padding: 4px 10px; min-height: 36px;
}
.lang.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.preview h2 { font-size: 16px; margin: 12px 0 4px; }
.mailhead div { display: flex; gap: 8px; padding: 4px 0; font-size: 14px; overflow-wrap: anywhere; }
.mailhead span { color: var(--muted); min-width: 44px; }
/* İmza önizlemesi: mailde olduğu gibi beyaz zeminde */
.signature-preview { margin-top: 8px; padding: 4px 12px 12px; background: #ffffff; color: #222; border-radius: 10px; overflow-x: auto; }
.signature { margin: 8px 0 0; padding: 0 10px; color: var(--muted); font: inherit; font-size: 14px; white-space: pre-wrap; }
.back { margin-top: 12px; padding: 10px; border-radius: 10px; background: var(--new-bg); color: var(--text); }
.backtitle { font-weight: 600; font-size: 14px; margin-bottom: 4px; color: var(--new); }
.back .stale-note { display: none; margin: 8px 0 0; font-size: 13px; color: var(--late); font-weight: 600; }
.back.stale > div:not(.backtitle) { opacity: .45; }
.back.stale .stale-note { display: block; }
.confirm { margin-top: 12px; padding: 12px; border-radius: 10px; border: 2px solid #16a34a; }
.confirm p { margin: 0 0 4px; font-weight: 600; }
.confirm .stale-warn { color: var(--late); }
[hidden] { display: none !important; }
.discard { text-align: center; padding-bottom: 8px; }
.link { background: none; border: 0; color: var(--late); text-decoration: underline; padding: 8px; }
.testtag { background: var(--wait-bg); color: var(--wait); border-radius: 6px; padding: 1px 6px; font-size: 12px; }
.flash { margin: 12px 16px 0; padding: 10px 12px; border-radius: 10px; font-weight: 600; }
.flash.ok { background: var(--done-bg); color: var(--done); }
.flash.error { background: var(--late-bg); color: var(--late); }
.flash.warn { background: var(--wait-bg); color: var(--wait); }
.push-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 10px 16px; padding: 10px 12px; border-radius: 10px; background: var(--new-bg); color: var(--text); font-size: 14px;
}
.push-bar.quiet { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.push-bar button { flex: none; }
.cron-late { color: var(--late); font-weight: 600; }
.cost { color: var(--muted); font-size: 13px; text-align: center; padding: 16px; }

/* 24 saattir yanıtsız */
.row.late { box-shadow: inset 4px 0 0 var(--late); }
.badge.late { background: var(--late-bg); color: var(--late); }

/* Kopyala düğmesi ve bildirimi */
.copy {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 8px; min-width: 32px; min-height: 32px; padding: 0 6px;
  font-size: 16px; line-height: 1; cursor: pointer;
}
.copy:active { background: var(--bg); }
.info .actions { align-items: center; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--top); color: var(--top-text); padding: 8px 16px; border-radius: 999px;
  font-size: 14px; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
