:root {
  --ink: #16141a;
  --ink-soft: #4b4655;
  --muted: #8b8694;
  --bg: #faf9f7;
  --surface: #ffffff;
  --line: #e8e5e0;
  --accent: #e8542f;
  --accent-dark: #c43e1d;
  --accent-soft: #fdeae4;
  --green: #1d8a55;
  --green-soft: #e3f4ea;
  --gold: #b98a1f;
  --gold-soft: #fbf2dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22, 20, 26, .05), 0 8px 24px rgba(22, 20, 26, .07);
  --shadow-lg: 0 4px 12px rgba(22, 20, 26, .08), 0 24px 48px rgba(22, 20, 26, .12);
  --font: 'Manrope', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.55; -webkit-font-smoothing: antialiased; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- Genel bilesenler ---------- */
.container { max-width: 1240px; margin: 0 auto; padding: 0 24px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 999px; padding: 12px 26px;
  font-size: 14px; font-weight: 700; letter-spacing: .01em;
  background: var(--ink); color: #fff; transition: all .18s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-accent { background: var(--accent); }
.btn-accent:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--ink); box-shadow: none; }
.btn-sm { padding: 7px 16px; font-size: 13px; }
.btn-danger { background: #fff0ee; color: #c0331b; }
.btn-danger:hover { background: #ffe2dd; box-shadow: none; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 14px;
  background: #fff; outline: none; transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ink); }
.field textarea { resize: vertical; min-height: 90px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 800; letter-spacing: .03em; }
.badge-rec { background: var(--gold-soft); color: var(--gold); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-accent { background: var(--accent-soft); color: var(--accent-dark); }
.badge-gray { background: #efedea; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 999px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); animation: toastIn .25s ease; }
.toast.err { background: #c0331b; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.modal-backdrop { position: fixed; inset: 0; background: rgba(22,20,26,.5); backdrop-filter: blur(3px); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: #fff; border-radius: 18px; padding: 28px; max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: toastIn .2s ease; }
.modal h3 { margin-bottom: 16px; font-size: 19px; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* ---------- Urun kartlari ---------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
.pcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; position: relative;
  transition: transform .18s ease, box-shadow .18s ease;
}
.pcard:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.pcard.dragging { opacity: .45; transform: scale(.97); }
.pcard .imgwrap { position: relative; aspect-ratio: 3/4; background: #f1efec; overflow: hidden; }
.pcard .imgwrap img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.pcard:hover .imgwrap img { transform: scale(1.04); }
.pcard .imgwrap .flag { position: absolute; top: 10px; left: 10px; }
.pcard .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pcard .pname { font-size: 13.5px; font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 36px; }
.pcard .pmeta { font-size: 12px; color: var(--muted); }
.pcard .prices { display: flex; align-items: baseline; gap: 8px; margin-top: 2px; }
.pcard .price { font-size: 16px; font-weight: 800; }
.pcard .oldprice { font-size: 12.5px; color: var(--muted); text-decoration: line-through; }
.pcard .earn { font-size: 12.5px; font-weight: 700; color: var(--green); background: var(--green-soft); padding: 4px 9px; border-radius: 8px; align-self: flex-start; }
.pcard .actions { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; }
.pcard .actions .btn { flex: 1; }
.sizes-row { display: flex; flex-wrap: wrap; gap: 4px; }
.size-chip { font-size: 10.5px; font-weight: 700; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--ink-soft); }

/* ---------- Panel duzeni ---------- */
.panel-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; background: var(--ink); color: #fff;
  display: flex; flex-direction: column; padding: 24px 16px; position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { font-size: 19px; font-weight: 800; letter-spacing: -.02em; padding: 0 12px 22px; }
.sidebar .logo span { color: var(--accent); }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 10px;
  font-size: 14px; font-weight: 600; color: rgba(255,255,255,.65); transition: all .15s;
}
.sidebar nav a:hover { color: #fff; background: rgba(255,255,255,.07); }
.sidebar nav a.active { color: #fff; background: rgba(255,255,255,.12); }
.sidebar nav a .nbadge { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 999px; }
.sidebar .foot { padding: 12px; font-size: 12.5px; color: rgba(255,255,255,.5); }
.sidebar .foot strong { color: #fff; display: block; font-size: 13.5px; }
.main { flex: 1; padding: 30px 34px 60px; min-width: 0; }
.main h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 4px; }
.main .sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.stat .lbl { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat .val { font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: -.02em; }
.stat .val small { font-size: 14px; color: var(--muted); font-weight: 600; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; align-items: center; }
.toolbar input[type="search"], .toolbar select {
  border: 1.5px solid var(--line); border-radius: 999px; padding: 10px 18px; background: #fff; outline: none; font-size: 14px;
}
.toolbar input[type="search"] { min-width: 240px; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--ink); }
.toolbar .spacer { flex: 1; }

table.dtable { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.dtable th { text-align: left; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 13px 16px; border-bottom: 1px solid var(--line); background: #fcfbfa; }
.dtable td { padding: 13px 16px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
.dtable tr:last-child td { border-bottom: none; }
.dtable-wrap { border-radius: var(--radius); overflow: auto; border: 1px solid var(--line); }
.dtable-wrap table { border: none; }

.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 24px; }
.pagination button { border: 1.5px solid var(--line); background: #fff; border-radius: 10px; padding: 7px 14px; font-weight: 700; font-size: 13.5px; }
.pagination button.cur { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Surukle birak ---------- */
.dnd-layout { display: grid; grid-template-columns: 1fr 360px; gap: 22px; align-items: start; }
.dropzone {
  position: sticky; top: 20px; background: var(--surface); border: 2px dashed var(--line);
  border-radius: var(--radius); padding: 18px; min-height: 380px; max-height: calc(100vh - 40px);
  overflow-y: auto; transition: border-color .15s, background .15s;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone h3 { font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.dropzone .hint { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
.mini-item {
  display: flex; gap: 10px; align-items: center; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 8px; margin-bottom: 8px; cursor: grab;
}
.mini-item img { width: 44px; height: 56px; object-fit: cover; border-radius: 7px; background: #f1efec; }
.mini-item .mi-name { font-size: 12.5px; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mini-item .mi-price { font-size: 12px; color: var(--green); font-weight: 700; }
.mini-item .mi-x { margin-left: auto; border: none; background: none; color: var(--muted); font-size: 17px; padding: 4px 8px; border-radius: 7px; }
.mini-item .mi-x:hover { background: #fff0ee; color: #c0331b; }
.mini-item.dragging { opacity: .4; }

/* ---------- Sohbet ---------- */
.chat-layout { display: grid; grid-template-columns: 280px 1fr; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); height: calc(100vh - 200px); min-height: 460px; }
.chat-threads { border-right: 1px solid var(--line); overflow-y: auto; }
.chat-thread { padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s; }
.chat-thread:hover { background: #f7f5f2; }
.chat-thread.active { background: var(--accent-soft); }
.chat-folder { border-bottom: 1px solid var(--line); }
.cf-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; cursor: pointer; background: #fcfbfa; font-weight: 800; font-size: 13.5px; transition: background .12s; }
.cf-head:hover { background: #f7f5f2; }
.cf-arrow { font-size: 11px; color: var(--muted); width: 12px; }
.cf-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-count { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.chat-folder .chat-thread { padding-left: 30px; }
.chat-thread .ct-name { font-weight: 800; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.chat-thread .ct-last { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat-main { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 70%; padding: 10px 15px; border-radius: 16px; font-size: 14px; line-height: 1.45; }
.msg.mine { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 5px; }
.msg.theirs { align-self: flex-start; background: #f1efec; border-bottom-left-radius: 5px; }
.msg .mt { display: block; font-size: 10.5px; opacity: .55; margin-top: 3px; }
.chat-input { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; border: 1.5px solid var(--line); border-radius: 999px; padding: 11px 18px; outline: none; }
.chat-input input:focus { border-color: var(--ink); }

/* ---------- Mobil ---------- */
@media (max-width: 960px) {
  .panel-layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 300;
    flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 14px;
    box-shadow: 0 2px 12px rgba(22, 20, 26, .18);
  }
  .sidebar .logo { padding: 0; font-size: 17px; }
  /* Mobilde isim/rol metni gizlenir, Magazam/Cikis butonlari sag ustte kalir */
  .sidebar .foot { order: 2; margin-left: auto; padding: 0; font-size: 0; display: flex; align-items: center; }
  .sidebar .foot strong { display: none; }
  .sidebar .foot div { margin-top: 0 !important; }
  .sidebar nav {
    order: 3; width: 100%; flex: none; flex-direction: row; flex-wrap: nowrap;
    overflow-x: auto; gap: 6px; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar nav a { padding: 8px 14px; font-size: 13px; white-space: nowrap; flex-shrink: 0; background: rgba(255,255,255,.06); border-radius: 999px; }
  .main { padding: 20px 16px 50px; }
  .dnd-layout { grid-template-columns: 1fr; }
  .dropzone { position: static; max-height: none; min-height: 140px; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-threads { max-height: 200px; }
  .chat-main { height: 420px; }
}

@media (max-width: 640px) {
  .container { padding: 0 16px; }
  /* iOS'ta odaklanildiginda otomatik zoom olmamasi icin 16px */
  input, select, textarea { font-size: 16px; }

  .main { padding: 16px 14px 44px; }
  .main h1 { font-size: 20px; }
  .main .sub { font-size: 13px; margin-bottom: 18px; }

  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .pcard .body { padding: 10px 11px 12px; gap: 5px; }
  .pcard .pname { font-size: 12.5px; min-height: 34px; }
  .pcard .price { font-size: 15px; }
  .pcard .actions { flex-wrap: wrap; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
  .stat { padding: 14px 16px; }
  .stat .val { font-size: 21px; }

  .toolbar { gap: 8px; }
  .toolbar input[type="search"] { min-width: 0; flex: 1 1 100%; }
  .toolbar select { flex: 1; min-width: 0; }

  .dtable th { padding: 10px 12px; font-size: 11px; }
  .dtable td { padding: 10px 12px; font-size: 13px; }

  .pagination { flex-wrap: wrap; }

  .msg { max-width: 86%; }
  .chat-msgs { padding: 14px; }
  .chat-input { padding: 10px; }

  /* Modallar mobilde alttan acilan panel gibi davranir */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100%; border-radius: 20px 20px 0 0; padding: 22px 18px;
    padding-bottom: calc(22px + env(safe-area-inset-bottom));
    max-height: 92dvh; animation: sheetIn .25s ease;
  }

  .toast-wrap { width: calc(100% - 28px); }
  .toast { text-align: center; font-size: 13.5px; padding: 11px 18px; }
}

@keyframes sheetIn { from { opacity: 0; transform: translateY(48px); } to { opacity: 1; transform: none; } }
