:root {
  --bg: #f4f6f9; --panel: #ffffff; --line: #e3e7ee; --text: #18202c; --muted: #657083; --soft: #eef2f7;
  --accent: #2f6fde; --accent-soft: #e6eefc; --in: #ffffff; --out: #dcebff; --ok: #1d8a4c; --warn: #b26a00; --bad: #c0362c;
  --mask: #efe7ff; --mask-text: #5a3ea8; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f141b; --panel: #161d27; --line: #263142; --text: #e6ebf2; --muted: #93a0b4; --soft: #1c2531;
    --accent: #5b93f0; --accent-soft: #1d2b44; --in: #1c2531; --out: #1f3557; --mask: #2b2246; --mask-text: #c9b8ff; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--bad); }
button.link { border: none; background: none; color: var(--accent); padding: 2px 4px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 10px; width: 100%; }
textarea { resize: vertical; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
h1, h2, h3 { margin: 0 0 10px; font-weight: 600; }
h2 { font-size: 18px; } h3 { font-size: 15px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; } .row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 8px; border-radius: 99px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--ok); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); } .pill.acc { color: var(--accent); background: var(--accent-soft); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }
.mask { background: var(--mask); color: var(--mask-text); border-radius: 4px; padding: 0 4px; font-size: 12px; white-space: nowrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.notice { border-left: 3px solid var(--warn); background: var(--soft); padding: 8px 10px; border-radius: 6px; font-size: 13px; }
.notice.bad { border-color: var(--bad); } .notice.info { border-color: var(--accent); }
#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 6px; align-items: center; }
#toast .t { background: #1f2937; color: #fff; padding: 8px 14px; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.2); max-width: 90vw; }
#toast .t.bad { background: var(--bad); }

/* giriş */
.auth { max-width: 380px; margin: 9vh auto; padding: 0 16px; }
.auth .card { padding: 24px; }
.auth h1 { font-size: 20px; }
.auth .qr svg { width: 200px; height: 200px; background: #fff; border-radius: 8px; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--soft); padding: 2px 6px; border-radius: 4px; word-break: break-all; }

/* üst çubuk */
.shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.top { display: flex; align-items: center; gap: 12px; padding: 0 14px; height: 50px; background: var(--panel); border-bottom: 1px solid var(--line); flex-shrink: 0; }
.top .brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.top nav { display: flex; gap: 4px; }
.top nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; }
.top nav a.on { background: var(--accent-soft); color: var(--accent); }
.top .who { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.main { flex: 1; min-height: 0; display: flex; }
.page { flex: 1; overflow: auto; padding: 20px; }
.page-inner { max-width: 1200px; margin: 0 auto; }

/* sohbet düzeni */
.inbox { display: grid; grid-template-columns: 320px 1fr 300px; flex: 1; min-height: 0; }
.col { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--panel); }
.col.mid { background: var(--bg); }
.col.right { border-right: none; overflow: auto; }
.listhead { padding: 10px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.filters { display: flex; gap: 4px; flex-wrap: wrap; }
.filters button { padding: 3px 9px; font-size: 12px; border-radius: 99px; }
.filters button.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.chatlist { overflow: auto; flex: 1; }
.ci { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.ci:hover { background: var(--soft); } .ci.on { background: var(--accent-soft); }
.av { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; color: #fff; flex-shrink: 0; }
.ci .l1 { display: flex; justify-content: space-between; gap: 6px; }
.ci .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci .prev { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci .l3 { display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; }
.badge { background: var(--accent); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; min-width: 18px; text-align: center; }
.chathead { padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; min-height: 52px; }
.msgs { flex: 1; overflow: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: min(640px, 80%); padding: 7px 11px; border-radius: 12px; background: var(--in); border: 1px solid var(--line); align-self: flex-start; position: relative; }
.msg.out { background: var(--out); align-self: flex-end; border-color: transparent; }
.msg .meta { font-size: 11px; color: var(--muted); display: flex; gap: 8px; justify-content: flex-end; margin-top: 2px; align-items: center; }
.msg .who { font-size: 12px; color: var(--accent); font-weight: 600; margin-bottom: 2px; }
.msg .body { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg .quote { border-left: 3px solid var(--accent); padding: 2px 8px; margin-bottom: 4px; font-size: 12px; background: var(--soft); border-radius: 4px; color: var(--muted); }
.msg .fwd { font-size: 12px; color: var(--muted); font-style: italic; margin-bottom: 2px; }
.msg .att { margin: 4px 0; padding: 8px; background: var(--soft); border-radius: 8px; font-size: 13px; }
.msg .att img { max-width: 100%; max-height: 320px; border-radius: 6px; display: block; }
.msg .acts { display: none; position: absolute; top: -12px; right: 6px; gap: 2px; }
.msg:hover .acts { display: flex; }
.msg .acts button { padding: 1px 7px; font-size: 11px; }
.msg.service { align-self: center; background: none; border: none; color: var(--muted); font-size: 12px; }
.daysep { align-self: center; font-size: 11px; color: var(--muted); background: var(--soft); padding: 1px 10px; border-radius: 99px; margin: 6px 0; }
.st-sending { color: var(--muted); } .st-sent { color: var(--ok); } .st-failed { color: var(--bad); font-weight: 600; }
.composer { background: var(--panel); border-top: 1px solid var(--line); padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.composer textarea { min-height: 42px; max-height: 180px; }
.composer .replybar { font-size: 12px; background: var(--soft); padding: 4px 8px; border-radius: 6px; display: flex; justify-content: space-between; }
.typing { font-size: 12px; color: var(--warn); padding: 2px 14px; }
.empty { margin: auto; color: var(--muted); text-align: center; padding: 30px; }
.side { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.side section { border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.side section:last-child { border: none; }
.note { background: var(--soft); border-radius: 8px; padding: 8px; margin-top: 6px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.note .nm { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.canned { position: absolute; bottom: 100%; left: 0; right: 0; max-height: 260px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.canned div { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.canned div:hover { background: var(--soft); }

/* pano / yönetim */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.stat .n { font-size: 26px; font-weight: 700; } .stat .k { color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); background: var(--panel); border: 1px solid var(--line); }
.tabs a.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.stack > * + * { margin-top: 14px; }
.real { color: var(--bad); font-weight: 600; }
.leak { background: #fde8e6; color: var(--bad); padding: 8px; border-radius: 6px; }
.okbox { background: #e5f6ec; color: var(--ok); padding: 8px; border-radius: 6px; }
@media (prefers-color-scheme: dark) { .leak { background: #3a1d1b; } .okbox { background: #15301f; } }
pre.json { background: var(--soft); padding: 10px; border-radius: 8px; overflow: auto; max-height: 420px; font-size: 12px; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: var(--panel); border-radius: 12px; padding: 20px; width: min(520px, 100%); max-height: 90vh; overflow: auto; }
.back { display: none; }

@media (max-width: 1100px) { .inbox { grid-template-columns: 290px 1fr; } .col.right { display: none; } .inbox.info .col.right { display: flex; position: fixed; right: 0; top: 50px; bottom: 0; width: 320px; z-index: 30; box-shadow: -8px 0 24px rgba(0,0,0,.15); } }
@media (max-width: 720px) {
  .top nav a span { display: none; }
  .top .who .nm { display: none; }
  .inbox { grid-template-columns: 1fr; }
  .inbox .col.mid { display: none; }
  .inbox.open .col.left { display: none; }
  .inbox.open .col.mid { display: flex; }
  .inbox.info .col.right { width: 100%; }
  .back { display: inline-block; }
  .msg { max-width: 92%; }
  .page { padding: 12px; }
}
