* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f4f5f7; --card: #fff; --ink: #1a1a2e; --muted: #8a8a99;
  --line: #e8e8ef; --brand: #4f46e5; --brand-d: #4338ca;
  --green: #16a34a; --green-bg: #dcfce7; --red: #dc2626; --red-bg: #fee2e2;
  --amber: #d97706; --amber-bg: #fef3c7; --blue: #2563eb; --blue-bg: #dbeafe;
}
body { font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--ink); }

/* ---- Login ---- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--card); padding: 36px 32px; border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.1); width: 340px; display: flex; flex-direction: column; gap: 14px; }
.login-logo { font-size: 22px; font-weight: 800; text-align: center; }
.login-sub { text-align: center; color: var(--muted); margin-top: -8px; font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #555; }
.login-card input { padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }
.login-card input:focus { outline: none; border-color: var(--brand); }
.login-err { color: var(--red); font-size: 13px; text-align: center; }

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: var(--ink); color: #fff; display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; }
.brand { font-size: 18px; font-weight: 800; padding: 22px 22px 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px; }
.nav a { color: #c7c7d6; text-decoration: none; padding: 11px 14px; border-radius: 8px; font-size: 14px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; color: #a0a0b8; display: flex; justify-content: space-between; align-items: center; }
.btn-link { background: none; border: none; color: #ff9b9b; cursor: pointer; font-size: 13px; }
.content { margin-left: 230px; flex: 1; padding: 28px 32px; max-width: 1100px; }

/* ---- Genel ---- */
h1 { font-size: 22px; margin-bottom: 4px; }
.subtitle { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.loading { color: var(--muted); padding: 40px; text-align: center; }
.card { background: var(--card); border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 20px; }
.card h2 { font-size: 15px; margin-bottom: 14px; }

/* ---- Stat kartlari ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--card); border-radius: 12px; padding: 18px 20px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.stat .n { font-size: 30px; font-weight: 800; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat.green .n { color: var(--green); } .stat.red .n { color: var(--red); }
.stat.amber .n { color: var(--amber); } .stat.blue .n { color: var(--blue); }

/* ---- Tablo ---- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
tbody tr:hover { background: #fafafe; }
.tbl-wrap { overflow-x: auto; }

/* ---- Rozetler ---- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.sent { background: var(--green-bg); color: var(--green); }
.badge.failed, .badge.failed_retry { background: var(--red-bg); color: var(--red); }
.badge.queued { background: var(--amber-bg); color: var(--amber); }
.badge.sending { background: var(--blue-bg); color: var(--blue); }
.badge.proj { background: #eef; color: #556; }

/* ---- Butonlar / formlar ---- */
.btn { padding: 9px 16px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; background: #ececf3; color: #444; }
.btn:hover { background: #e2e2ee; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-d); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
input, select, textarea { font-family: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: #555; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 180px; }
.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }

/* ---- Pagination ---- */
.pager { display: flex; gap: 8px; align-items: center; margin-top: 14px; }

/* ---- Şablon editörü ---- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.editor-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tpl-code { width: 100%; height: 68vh; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; line-height: 1.5; border: 1px solid var(--line); border-radius: 8px; padding: 12px; resize: vertical; background: #fbfbfe; }
.tpl-code:focus { outline: none; border-color: var(--brand); }
.editor-prev { height: 68vh; }
.editor-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.etab { padding: 8px 16px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; color: #666; }
.etab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.vform { display: flex; flex-direction: column; gap: 16px; }
.vfield { display: flex; flex-direction: column; gap: 7px; }
.vfield label { font-size: 13px; font-weight: 600; color: #555; }
.color-row { display: flex; gap: 8px; align-items: center; }
.vc-color { width: 46px; height: 40px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: #fff; }
.vc-hex { width: 110px; }
.vc-text { width: 100%; }
@media (max-width: 820px) {
  .editor-split { grid-template-columns: 1fr; }
  .tpl-code { height: 40vh; }
  .editor-prev { height: 50vh; }
}

/* ---- Modal ---- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 12px; padding: 24px; max-width: 640px; width: 100%; max-height: 86vh; overflow: auto; position: relative; }
.modal-close { position: absolute; top: 14px; right: 16px; background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 14px; font-size: 14px; margin: 14px 0; }
.kv .k { color: var(--muted); }
.preview-frame { width: 100%; height: 460px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.key-reveal { background: var(--green-bg); border: 1px solid #b7ebc6; border-radius: 8px; padding: 14px; margin-top: 12px; }
.key-reveal .mono { word-break: break-all; font-size: 14px; font-weight: 600; }

/* ---- Responsive ---- */
@media (max-width: 760px) {
  .sidebar { width: 60px; }
  .brand { font-size: 0; padding: 18px 0; text-align: center; }
  .brand::before { content: "✉️"; font-size: 22px; }
  .nav a { font-size: 0; text-align: center; padding: 12px 0; }
  .nav a::first-letter { font-size: 18px; }
  .sidebar-foot { display: none; }
  .content { margin-left: 60px; padding: 18px; }
}
