/* ============ Tasarim belirteçleri (tokens) ============ */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --sidebar: #101728;
  --sidebar-2: #1b2438;
  --sidebar-text: #aeb7c7;
  --sidebar-active: #ffffff;
  --border: #e6e8ec;
  --border-strong: #d5d9df;
  --text: #111827;
  --text-muted: #6b7280;
  --text-faint: #9aa1ac;

  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-soft: #eef2ff;

  --success: #059669;
  --success-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn: #d97706;

  /* Asama renkleri */
  --st-new: #64748b;
  --st-contacted: #0ea5e9;
  --st-qualified: #8b5cf6;
  --st-proposal: #f59e0b;
  --st-negotiation: #f97316;
  --st-won: #10b981;
  --st-lost: #ef4444;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 23, 40, 0.04), 0 1px 3px rgba(16, 23, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 23, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 23, 40, 0.16);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --sidebar-w: 236px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }

/* Klavye ile gezinme icin gorunur odak */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============ Butonlar ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 15px; font-size: 13.5px; font-weight: 600; font-family: inherit;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, color .12s;
  background: var(--surface); color: var(--text);
}
.btn:active { transform: translateY(0.5px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.94); }
.btn-outline-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.icon-btn {
  background: transparent; border: none; cursor: pointer; font-size: 20px;
  color: var(--text-muted); padding: 6px 10px; border-radius: var(--radius-sm);
}
.icon-btn:hover { background: var(--surface-2); }

/* ============ Giris ekrani ============ */
.login-screen {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 100% -10%, #e7e9ff 0%, transparent 55%),
    radial-gradient(900px 500px at -10% 110%, #e5f5ef 0%, transparent 50%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px;
  padding: 34px 30px; box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 26px; }
.login-brand h1 { font-size: 20px; margin: 0; letter-spacing: -0.3px; }
.login-brand p { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: #fff; font-weight: 800; font-size: 20px;
  display: grid; place-items: center; box-shadow: var(--shadow-sm);
}
#login-form label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin: 14px 0 6px; }
#login-form input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; background: var(--surface-2);
}
#login-form input:focus { background: #fff; border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
#login-btn { margin-top: 22px; padding: 11px; }
.login-foot { text-align: center; color: var(--text-faint); font-size: 12px; margin: 18px 0 0; }
.form-error {
  margin-top: 14px; background: var(--danger-soft); color: var(--danger);
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
}

/* ============ Uygulama iskeleti ============ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--sidebar);
  display: flex; flex-direction: column; padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 11px; color: #fff;
  font-weight: 700; font-size: 15.5px; padding: 4px 8px 20px; letter-spacing: -0.2px;
}
.sidebar-brand .brand-mark { width: 32px; height: 32px; font-size: 16px; border-radius: 9px; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px;
  color: var(--sidebar-text); border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--sidebar-2); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-ico { width: 20px; text-align: center; font-size: 15px; opacity: .9; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.07); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px; flex: none; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.menu-toggle { display: none; }

.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft);
  color: var(--primary-600); display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta span:first-child { font-weight: 600; font-size: 13px; }
.role-badge {
  font-size: 10.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
}

.view { padding: 24px; max-width: 1360px; width: 100%; }

/* ============ Genel bilesenler ============ */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 21px; letter-spacing: -0.4px; }
.page-head .sub { color: var(--text-muted); font-size: 13.5px; margin-top: 3px; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px; }

/* KPI kartlari */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi .kpi-label { color: var(--text-muted); font-size: 12.5px; font-weight: 600; }
.kpi .kpi-value { font-size: 27px; font-weight: 800; letter-spacing: -0.8px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi .kpi-sub { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.kpi .kpi-accent { position: absolute; top: 0; left: 0; height: 3px; width: 100%; }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.section-title { font-size: 14.5px; font-weight: 700; margin: 0 0 14px; }

/* ============ Tablo ============ */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; padding: 11px 14px; color: var(--text-muted); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr { cursor: pointer; transition: background .1s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }
.cell-strong { font-weight: 600; }
.cell-muted { color: var(--text-muted); }
.cell-num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* Rozetler / etiketler */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.stage-new { color: var(--st-new); background: #f1f5f9; }
.stage-contacted { color: var(--st-contacted); background: #e0f2fe; }
.stage-qualified { color: var(--st-qualified); background: #f3e8ff; }
.stage-proposal { color: var(--st-proposal); background: #fef3c7; }
.stage-negotiation { color: var(--st-negotiation); background: #ffedd5; }
.stage-won { color: #047857; background: var(--success-soft); }
.stage-lost { color: var(--st-lost); background: #fee2e2; }
.role-pill { padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; background: var(--primary-soft); color: var(--primary-600); }
.role-pill.manager { background: #fff7ed; color: #c2410c; }
.role-pill.sales { background: #f1f5f9; color: #475569; }
.pill-off { background: #f3f4f6; color: #9ca3af; }

/* Araç çubuğu / filtreler */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search-box { position: relative; flex: 1; min-width: 200px; max-width: 340px; }
.search-box input {
  width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 13.5px; font-family: inherit; background: var(--surface);
}
.search-box::before { content: "⌕"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 16px; }
select.input, input.input, textarea.input {
  padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: inherit; background: var(--surface); color: var(--text);
}
select.input:focus, input.input:focus, textarea.input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }

/* ============ Pipeline (Kanban) ============ */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.kanban-col {
  flex: 0 0 262px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 210px);
}
.kanban-col.drag-over { outline: 2px dashed var(--primary); outline-offset: -2px; background: var(--primary-soft); }
.kanban-col-head {
  padding: 12px 14px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
.kanban-col-head .k-title { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.kanban-col-head .k-bar { width: 8px; height: 8px; border-radius: 50%; }
.kanban-col-head .k-count { font-size: 11.5px; color: var(--text-muted); font-weight: 600; background: #fff; border: 1px solid var(--border); padding: 1px 8px; border-radius: 999px; }
.kanban-col-sum { font-size: 11.5px; color: var(--text-muted); padding: 6px 14px; border-bottom: 1px dashed var(--border); font-variant-numeric: tabular-nums; }
.kanban-list { padding: 10px; display: flex; flex-direction: column; gap: 9px; overflow-y: auto; flex: 1; min-height: 60px; }
.k-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 12px; box-shadow: var(--shadow-sm); cursor: grab; transition: box-shadow .12s, transform .06s;
}
.k-card:hover { box-shadow: var(--shadow-md); }
.k-card:active { cursor: grabbing; }
.k-card.dragging { opacity: .5; }
.k-card .k-name { font-weight: 650; font-size: 13.5px; }
.k-card .k-company { color: var(--text-muted); font-size: 12px; margin-top: 1px; }
.k-card .k-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; }
.k-card .k-value { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.k-owner { width: 24px; height: 24px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-600); display: grid; place-items: center; font-size: 10.5px; font-weight: 700; }

/* ============ Lead detay ============ */
.detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.back-link { color: var(--text-muted); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.back-link:hover { color: var(--primary); }
.info-list { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.info-list .info-item { min-width: 0; }
.info-list .k { font-size: 11.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.info-list .v { font-size: 14px; margin-top: 3px; word-break: break-word; }

/* Zaman cizelgesi */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 15px; top: 30px; bottom: 0; width: 2px; background: var(--border); }
.tl-ico { width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 13px; z-index: 1; }
.tl-note { background: #eef2ff; color: var(--primary-600); }
.tl-call { background: #dcfce7; color: #15803d; }
.tl-email { background: #e0f2fe; color: #0369a1; }
.tl-meeting { background: #fef3c7; color: #b45309; }
.tl-body { flex: 1; min-width: 0; }
.tl-body .tl-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.tl-body .tl-text { font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.tl-del { opacity: 0; font-size: 12px; color: var(--text-faint); cursor: pointer; }
.tl-item:hover .tl-del { opacity: 1; }
.tl-del:hover { color: var(--danger); }

.activity-composer { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.type-tabs { display: flex; gap: 6px; }
.type-tab { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border-strong); background: #fff; font-size: 12.5px; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.type-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Görev satırı */
.task-row { display: flex; align-items: flex-start; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.task-row:last-child { border-bottom: none; }
.task-check { width: 19px; height: 19px; flex: none; margin-top: 1px; border: 1.8px solid var(--border-strong); border-radius: 6px; cursor: pointer; display: grid; place-items: center; color: #fff; transition: background .12s, border-color .12s; }
.task-check.done { background: var(--success); border-color: var(--success); }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 13.5px; }
.task-title.done { text-decoration: line-through; color: var(--text-faint); font-weight: 500; }
.task-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.due-over { color: var(--danger); font-weight: 600; }
.due-soon { color: var(--warn); font-weight: 600; }

/* Bos durum */
.empty { text-align: center; padding: 46px 20px; color: var(--text-muted); }
.empty .empty-ico { font-size: 34px; opacity: .35; margin-bottom: 10px; }
.empty p { margin: 4px 0 16px; }

/* Basit cubuk grafik */
.bar-chart { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 54px; align-items: center; gap: 12px; font-size: 12.5px; }
.bar-row .bar-label { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 9px; background: #eef0f3; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.bar-row .bar-val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ============ Modal ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 20px; z-index: 100; animation: fade .12s ease;
}
.modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: pop .14s ease;
}
.modal.wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 12px; }
.modal-head h3 { margin: 0; font-size: 17px; letter-spacing: -0.3px; }
.modal-body { padding: 6px 22px 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px 20px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.form-row textarea { resize: vertical; min-height: 74px; }
.form-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.modal-error { background: var(--danger-soft); color: var(--danger); padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; }

/* ============ Toast ============ */
.toast-root { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: #111827; color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-lg); min-width: 220px; max-width: 340px; animation: slideIn .18s ease;
  display: flex; align-items: center; gap: 10px;
}
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }
.toast .t-ico { font-weight: 800; }

/* Yukleme */
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
.loading-center { display: grid; place-items: center; min-height: 260px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ============ Duyarli (responsive) ============ */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .detail-grid { grid-template-columns: 1fr; }
  .form-cols { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .view { padding: 16px; }
  .user-meta { display: none; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 45; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
