:root {
  --blue:        #2563eb;
  --blue-dark:   #1e40af;
  --blue-light:  #dbeafe;
  --red:         #dc2626;
  --red-light:   #fee2e2;
  --green:       #16a34a;
  --green-light: #dcfce7;
  --gray:        #64748b;
  --gray-light:  #f1f5f9;
  --border:      #e2e8f0;
  --text:        #1e293b;
  --text-muted:  #64748b;
  --card:        #ffffff;
  --bg:          #f8fafc;
  --nav-bg:      #0f172a;
  --radius:      8px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:   0 4px 12px rgba(0,0,0,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Navigation ───────────────────────────────────────────────────────────── */
.navbar {
  background: var(--nav-bg);
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 54px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 28px;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.nav-brand {
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
}
.nav-links { display: flex; gap: 2px; }
.nav-link {
  color: #94a3b8;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #e2e8f0; }
.nav-link.active { background: var(--blue); color: #fff; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.main-content { width: 90%; max-width: none; margin: 0 auto; padding: 24px 20px; }
.page { display: none; }
.page.active { display: block; }

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title { font-size: 21px; font-weight: 700; }
.header-actions { display: flex; gap: 8px; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card.p0 { padding: 0; overflow: hidden; }
.filter-card { padding: 14px 18px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
  line-height: 1;
}
.btn:hover  { opacity: .86; }
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--blue);  color: #fff; }
.btn-success  { background: var(--green); color: #fff; }
.btn-danger   { background: var(--red);   color: #fff; }
.btn-secondary{ background: var(--gray-light); color: var(--text); border: 1px solid var(--border); }
.btn-ghost    { background: transparent; color: var(--gray); border: 1px solid var(--border); }
.btn-sm       { padding: 4px 10px; font-size: 12px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: #fff;
  color: var(--text);
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

.filter-row  { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 130px; }
.filter-group label { font-size: 11.5px; color: var(--text-muted); font-weight: 600; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .3px; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  padding: 10px 14px;
  background: var(--gray-light);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .3px;
  white-space: nowrap;
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
tfoot td {
  padding: 10px 14px;
  font-weight: 700;
  background: var(--gray-light);
  border-top: 2px solid var(--border);
  font-size: 13px;
}
.td-actions { display: flex; gap: 5px; flex-wrap: nowrap; justify-content: flex-end; }
.td-actions .btn-icon, .td-actions .btn { flex: 0 0 auto; }
.table-wrapper { position: relative; overflow-x: auto; }
table { width: 100%; }
/* Long text columns wrap nicely */
td .nav-cell-link, td span.nav-cell-link {
  white-space: normal !important;
  word-break: break-word;
  display: inline-block;
  line-height: 1.25;
}
/* Sticky last (İşlem) column — always visible */
table th:last-child,
table td:last-child {
  position: sticky;
  right: 0;
  background: #fff;
  z-index: 2;
  box-shadow: -8px 0 12px -8px rgba(0,0,0,0.10);
  white-space: nowrap;
  min-width: 90px;
}
thead th:last-child { background: var(--gray-light); }
tbody tr:hover td:last-child { background: #f8fafc; }
tfoot td:last-child { background: var(--gray-light); }

/* Icon buttons used in sales table */
.btn-icon {
  border: 1px solid var(--border);
  background: #fff;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background .12s, border-color .12s;
}
.btn-icon:hover { background: #f1f5f9; }
.btn-icon-edit:hover { border-color: #2563eb; background: #eff6ff; }
.btn-icon-del:hover  { border-color: #dc2626; background: #fee2e2; }

/* ── Dashboard ────────────────────────────────────────────────────────────── */
.dashboard-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
}
.chart-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 20px;
}
.chart-container { position: relative; width: 240px; height: 240px; }
.chart-legend {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}
.legend-dot {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 50%;
}
.legend-dot.blue { background: var(--blue); }
.legend-dot.red  { background: var(--red);  }

.stat-group { display: flex; flex-direction: column; gap: 12px; }
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
}
.stat-card.highlight { border-left: 4px solid var(--blue); }
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 8px;
}
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.text-blue  { color: var(--blue); }
.text-red   { color: var(--red);  }
.text-green { color: var(--green);}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
}

/* ── Employee cards ───────────────────────────────────────────────────────── */
.employee-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.employee-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.employee-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.employee-name { font-size: 15px; font-weight: 700; }
.employee-card-actions { display: flex; gap: 6px; }

.week-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 10px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--gray-light);
  margin-bottom: 6px;
}
.stat-row:last-child { margin-bottom: 0; }
.stat-row-label { font-size: 12px; color: var(--text-muted); }
.stat-row-value { font-weight: 700; font-size: 13px; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.22);
  width: min(560px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-close-btn {
  background: none;
  border: none;
  font-size: 17px;
  cursor: pointer;
  color: var(--gray);
  line-height: 1;
  padding: 4px 6px;
  border-radius: 4px;
}
.modal-close-btn:hover { background: var(--gray-light); }
.modal-body { padding: 22px 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 300;
  max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--green); }
.toast.error   { background: var(--red);   }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Mode toggle ──────────────────────────────────────────────────────────── */
.mode-toggle { display: flex; gap: 0; }
.mode-toggle .btn { border-radius: 0; border: 1px solid var(--border); margin-right: -1px; }
.mode-toggle .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.mode-toggle .btn:last-child  { border-radius: 0 var(--radius) var(--radius) 0; margin-right: 0; }

/* ── Dashboard detail section ─────────────────────────────────────────────── */
#alltime-details { margin-top: 16px; }

.dash-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.detail-card-header {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
  background: var(--gray-light);
}

/* ── Expense target toggle ────────────────────────────────────────────────── */
.expense-target-toggle {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.target-btn {
  padding: 7px 18px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--gray-light);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background .12s, border-color .12s, color .12s;
}
.target-btn:hover:not(.active) {
  background: var(--blue-light);
  border-color: var(--blue);
  color: var(--blue);
}
.target-btn.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* ── Upcoming payments alert ──────────────────────────────────────────────── */
.upcoming-card {
  border-left: 4px solid #f59e0b;
  background: #fffbeb;
  margin-bottom: 0;
}
.upcoming-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  color: #92400e;
  padding: 12px 20px;
  border-bottom: 1px solid #fde68a;
}
.upcoming-icon {
  font-size: 16px;
}

/* ── Auto-generated expense rows ──────────────────────────────────────────── */
.auto-row {
  background: #fafff8;
  opacity: 0.92;
}
.auto-label {
  font-size: 11px;
  color: #64748b;
  font-style: italic;
  padding: 2px 6px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
}

/* ── Due date badge ───────────────────────────────────────────────────────── */
.due-date-badge {
  font-size: 12px;
  background: #eff6ff;
  color: #1d4ed8;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #bfdbfe;
  white-space: nowrap;
}

/* ── Purchase tracking ────────────────────────────────────────────────────── */
.upcoming-purchase-card {
  border-left-color: #dc2626;
  background: #fff5f5;
}
.upcoming-purchase-card .upcoming-header {
  color: #7f1d1d;
  border-bottom-color: #fecaca;
}

.pur-type-badge.payable    { background:#fee2e2; color:#dc2626; }
.pur-type-badge.receivable { background:#dcfce7; color:#16a34a; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 800px) {
  .dashboard-layout  { grid-template-columns: 1fr; }
  .dash-detail-grid  { grid-template-columns: 1fr; }
  .chart-card        { padding: 20px; }
  .chart-container   { width: 200px; height: 200px; }
  .form-grid         { grid-template-columns: 1fr; }
}

.btn-price-pick {
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #eff6ff;
  color: #1d4ed8;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-price-pick:hover { background: #dbeafe; }


/* ── Auth / login ─────────────────────────────────────────────────────────── */
#login-screen {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: var(--nav-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,.4);
  padding: 32px 30px 26px;
  width: min(380px, 100%);
}
.login-brand {
  font-size: 24px;
  font-weight: 800;
  color: var(--nav-bg);
  margin-bottom: 4px;
  letter-spacing: .3px;
}
.login-sub { color: #64748b; font-size: 13.5px; margin-bottom: 22px; }

.nav-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}
#nav-user-name { color: #cbd5e1; font-size: 13px; }
.nav-logout {
  background: rgba(255,255,255,.08);
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12.5px;
  cursor: pointer;
  transition: background .12s;
}
.nav-logout:hover { background: rgba(220,38,38,.65); border-color: transparent; }

/* ── Satışçı rolü: alış fiyatı / kar kolonları gizli ─────────────────────────
   Satışlar tablosu kolonları: 1 TARİH, 2 ÇALIŞAN, 3 MÜŞTERİ, 4 ÜRÜN, 5 FAT.NO,
   6 MİKTAR, 7 BRM.AĞ, 8 FAT.ALIŞ, 9 FAT.SATIŞ, 10 KAR, 11 KAR%, 12 VADE, 13 İŞLEM */
body.role-satisci #page-sales thead th:nth-child(7),
body.role-satisci #page-sales tbody td:nth-child(7),
body.role-satisci #page-sales thead th:nth-child(9),
body.role-satisci #page-sales tbody td:nth-child(9),
body.role-satisci #page-sales thead th:nth-child(10),
body.role-satisci #page-sales tbody td:nth-child(10) { display: none; }
body.role-satisci #page-sales tfoot { display: none; }
.nav-links { overflow-x: auto; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }

/* ── Muhasebe takvimi ─────────────────────────────────────────────── */
.acc-cal-head { display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.acc-cal-head .acc-title { font-size:18px; font-weight:700; min-width:170px; text-align:center; }
.acc-totals { display:flex; gap:18px; flex-wrap:wrap; font-size:13px; margin-bottom:12px; color:#334155; }
.acc-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:6px; }
.acc-weekhead { margin-bottom:6px; }
.acc-wk { text-align:center; font-size:12px; font-weight:600; color:#64748b; padding:4px 0; }
.acc-cell { position:relative; min-height:74px; border:1px solid #e2e8f0; border-radius:8px; padding:5px 6px; background:#fff; transition:.12s; }
.acc-cell:hover { filter:brightness(.97); }
.acc-empty { background:transparent; border-color:transparent; min-height:74px; }
.acc-daynum { font-size:13px; font-weight:600; color:#334155; }
.acc-today-num { background:#1d4ed8; color:#fff; border-radius:50%; padding:1px 6px; }
.acc-today { outline:2px dashed #93c5fd; }
.acc-dot { position:absolute; top:7px; right:7px; width:9px; height:9px; border-radius:50%; }
.acc-amt { position:absolute; bottom:16px; left:6px; font-size:12px; font-weight:700; color:#0f172a; }
.acc-cnt { position:absolute; bottom:3px; left:6px; font-size:10px; color:#64748b; }
.acc-io { display:block; font-size:10px; font-weight:600; line-height:1.28; margin-left:1px; }
.acc-bal { position:absolute; bottom:3px; right:6px; font-size:11px; font-weight:700; }
.acc-legend { display:flex; gap:16px; flex-wrap:wrap; margin-top:12px; font-size:12px; color:#475569; }
.acc-legend i { display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:5px; vertical-align:middle; }
.acc-drawer-head { padding:10px 4px; font-size:14px; color:#334155; }
.acc-badge { padding:2px 8px; border-radius:10px; font-size:11px; font-weight:600; white-space:nowrap; }
/* Liste dip toplam çubuğu + sayfalama (Satışlar / Cari Takip) */
.sales-totalbar { display:flex; flex-wrap:wrap; gap:10px 22px; align-items:center; background:#f8fafc; border:1px solid #e2e8f0;
  border-radius:10px; padding:11px 16px; margin-bottom:12px; }
.sales-totalbar .stb-item { display:flex; flex-direction:column; line-height:1.2; }
.sales-totalbar .stb-item b { font-size:16px; color:#0f172a; }
.sales-totalbar .stb-item small { color:#94a3b8; font-weight:500; }
.sales-totalbar .stb-lbl { font-size:11px; text-transform:uppercase; letter-spacing:.03em; color:#64748b; font-weight:600; }
.list-pager { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:10px; padding:12px 14px; border-top:1px solid #eef2f7; }
.list-pager .sales-pager-left, .list-pager .sales-pager-right { display:flex; align-items:center; gap:10px; }
.list-pager .sales-pager-left label { font-size:13px; color:#64748b; }
.list-pager button:disabled { opacity:.4; cursor:default; }
.acc-pager { display:flex; align-items:center; justify-content:flex-end; gap:10px; padding:8px 4px 2px; font-size:12px; color:#64748b; }
.acc-pager button { min-width:30px; }
.acc-pager button:disabled { opacity:.4; cursor:default; }
.acc-two { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
@media (max-width:900px){ .acc-two{ grid-template-columns:1fr; } .acc-cell{ min-height:60px; } }


/* SIDEBAR-V1 ───────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 220px;
  background: var(--nav-bg); display: flex; flex-direction: column;
  z-index: 150; box-shadow: 2px 0 8px rgba(0,0,0,.15);
}
.sidebar-brand {
  color: #fff; font-size: 16px; font-weight: 700; letter-spacing: .3px;
  padding: 18px 20px 14px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px 20px; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 3px; }
.nav-group { margin-bottom: 14px; }
.nav-group-title {
  color: #64748b; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; padding: 4px 12px 6px;
}
.nav-link {
  display: block; color: #cbd5e1; text-decoration: none;
  padding: 8px 12px; border-radius: 7px; cursor: pointer;
  font-size: 13.5px; margin-bottom: 1px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: var(--blue); color: #fff; font-weight: 600; }
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.08); padding: 12px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
#nav-user-name { color: #cbd5e1; font-size: 12.5px; }
.nav-logout {
  background: rgba(255,255,255,.08); color: #e2e8f0;
  border: 1px solid rgba(255,255,255,.15); border-radius: 6px;
  padding: 6px 12px; font-size: 12.5px; cursor: pointer; transition: background .12s;
}
.nav-logout:hover { background: rgba(220,38,38,.65); border-color: transparent; }

.main-content { width: auto; max-width: none; margin: 0 0 0 220px; padding: 24px 28px; }

.sidebar-toggle {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 160;
  background: var(--nav-bg); color: #fff; border: none; border-radius: 8px;
  width: 42px; height: 42px; font-size: 18px; cursor: pointer; box-shadow: var(--shadow-md);
}
@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .main-content { margin-left: 0; padding-top: 62px; }
  .sidebar-toggle { display: block; }
}

/* ── Toplama Listesi (satışçı mobil ana ekran) ─────────────────────────── */
.col-card { max-width: 760px; }
.col-periods { display:flex; gap:8px; flex-wrap:wrap; }
.col-pill { flex:1 1 72px; padding:11px 8px; border:1px solid #e2e8f0; border-radius:10px; background:#fff;
  font-weight:600; font-size:14px; color:#475569; cursor:pointer; transition:.12s; }
.col-pill.active { background:#2563eb; border-color:#2563eb; color:#fff; }
.col-search { margin:12px 0 4px; }
.col-summary { font-size:13px; color:#64748b; padding:6px 2px 12px; }
.col-list { display:flex; flex-direction:column; gap:8px; }
.col-item { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:12px 14px;
  border:1px solid #eef2f7; border-radius:12px; background:#fff; cursor:pointer; }
.col-item:active { background:#f1f5f9; }
.col-cust { font-weight:700; color:#0f172a; font-size:15px; line-height:1.25; }
.col-meta { font-size:12px; color:#94a3b8; margin-top:3px; }
.col-amt { font-weight:800; color:#16a34a; white-space:nowrap; font-size:15px; text-align:right; }
.col-rem { display:block; font-size:11px; color:#ca8a04; font-weight:600; }
.col-empty { padding:26px; text-align:center; color:#94a3b8; }
/* satışçı: cari'de rep filtresi görünmesin (zaten sadece kendi carileri) */
body.role-satisci #main-rep-filter { display:none; }

/* Ziyaret geçmişi (son 10) */
.visit-list { display:flex; flex-direction:column; gap:6px; max-height:240px; overflow-y:auto; }
.visit-item { border:1px solid #eef2f7; border-radius:8px; padding:8px 10px; background:#f8fafc; }
.visit-when { font-size:11px; color:#94a3b8; font-weight:600; }
.visit-note { font-size:13.5px; color:#334155; margin-top:2px; white-space:pre-wrap; }

/* satışçı: fiyat listesinde ALIŞ fiyatı kolonu gizli (asla görmesin) */
body.role-satisci .pl-alis { display:none; }

/* satışçı: maliyet/kâr ve Kapı Peşin ile ilgili her şey gizli (boş olsa bile) */
body.role-satisci .sc-cost,
body.role-satisci .pl-kapi { display:none !important; }

/* ═══════════ RESPONSIVE — tablet & mobil (yalnız dar ekran; geniş ekran DEĞİŞMEZ) ═══════════ */
@media (max-width: 820px) {
  .main-content   { padding: 60px 16px 24px; }        /* drawer toggle için üst boşluk */
  .filter-group   { min-width: 0; flex: 1 1 170px; }
  .header-actions { flex-wrap: wrap; }
  .form-grid      { grid-template-columns: 1fr; }
  .table-wrapper  { -webkit-overflow-scrolling: touch; }
  .acc-two        { grid-template-columns: 1fr; }
  .dashboard-layout, .dash-detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .main-content   { padding: 58px 10px 20px; }
  .page-title     { font-size: 18px; }
  .page-header    { margin-bottom: 14px; gap: 8px; }
  .header-actions { width: 100%; }
  .header-actions .btn { flex: 1 1 auto; justify-content: center; }
  .filter-row     { gap: 8px; }
  .filter-group   { flex: 1 1 100%; min-width: 0; }
  .card           { padding: 14px; }
  .filter-card    { padding: 12px 14px; }
  table           { font-size: 12px; }
  th, td          { padding: 8px 9px; }
  .modal-overlay  { padding: 8px; }
  .modal-body     { padding: 16px; }
  .modal-header   { padding: 14px 16px; }
  .modal-footer   { padding: 12px 16px; }
  .modal-footer .btn { flex: 1 1 auto; justify-content: center; }
  .stat-value     { font-size: 22px; }
  .stat-card      { padding: 14px; }
  /* liste sayfalama alt alta */
  .list-pager     { flex-direction: column; align-items: stretch; gap: 8px; }
  .list-pager .sales-pager-left, .list-pager .sales-pager-right { justify-content: space-between; }
  /* dip toplam çubuğu */
  .sales-totalbar { gap: 8px 16px; padding: 10px 12px; }
  .sales-totalbar .stb-item b { font-size: 15px; }
  /* muhasebe takvimi — sıkışık ama okunur */
  .acc-grid   { gap: 3px; }
  .acc-cell   { min-height: 50px; padding: 3px 4px; }
  .acc-daynum { font-size: 11px; }
  .acc-amt    { font-size: 9.5px; bottom: 14px; }
  .acc-cnt    { font-size: 9px; }
  .acc-io     { font-size: 9px; }
  .acc-bal    { font-size: 9.5px; }
  .acc-totals, .acc-legend { font-size: 11px; gap: 6px 10px; }
  .acc-title  { font-size: 15px; }
}

/* Mobil drawer backdrop + dashboard dar-ekran düzeni (geniş ekran değişmez) */
.sidebar-backdrop { display: none; }
@media (max-width: 820px) {
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 140; }
  .dash-donuts { grid-template-columns: 1fr !important; }
  .dash-summary-flex { flex-direction: column; align-items: stretch; gap: 14px; }
  .dash-summary-flex > div:first-child { margin: 0 auto; }
}

/* Çoklu ürün filtresi chip'leri (Satışlar) */
.chip-box { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:6px; }
.chip { display:inline-flex; align-items:center; gap:6px; background:#eff6ff; color:#1d4ed8;
        border:1px solid #bfdbfe; border-radius:14px; padding:3px 8px 3px 10px; font-size:12px;
        font-weight:600; line-height:1; white-space:nowrap; }
.chip-x { cursor:pointer; font-size:15px; line-height:1; color:#3b82f6; padding:0 1px; border-radius:50%; }
.chip-x:hover { background:#dbeafe; color:#1e3a8a; }

/* Tik'li çoklu-seçim dropdown (Satışlar ürün filtresi) */
.ms { position: relative; }
.ms-toggle { display:flex; align-items:center; justify-content:space-between; gap:8px; width:100%;
             cursor:pointer; text-align:left; background:#fff; font-weight:500; }
.ms-toggle .ms-placeholder { color:#94a3b8; font-weight:400; }
.ms-caret { color:#94a3b8; font-size:11px; flex-shrink:0; }
.ms-menu { position:absolute; top:calc(100% + 4px); left:0; z-index:200; width:300px; max-width:min(92vw,340px);
           background:#fff; border:1px solid #e2e8f0; border-radius:10px; box-shadow:0 8px 28px rgba(0,0,0,.14); padding:8px; }
.ms-search { width:100%; margin-bottom:6px; }
.ms-tools { display:flex; align-items:center; justify-content:space-between; padding:2px 4px 6px;
            border-bottom:1px solid #f1f5f9; margin-bottom:4px; }
.ms-allrow { display:flex; align-items:center; gap:6px; font-size:12px; color:#475569; cursor:pointer; font-weight:600; }
.ms-clear { font-size:12px; color:#2563eb; cursor:pointer; text-decoration:underline; }
.ms-list { max-height:240px; overflow-y:auto; }
.ms-item { display:flex; align-items:center; gap:8px; padding:6px; border-radius:6px; cursor:pointer;
           font-size:13px; color:#1e293b; }
.ms-item:hover { background:#eff6ff; }
.ms-item input { flex-shrink:0; cursor:pointer; }
.ms-item span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ms-empty { padding:14px; text-align:center; color:#94a3b8; font-size:13px; }

/* Tahsilatlar sayfası */
.th-tabs { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px; }
.th-tab { padding:7px 14px; border:1px solid #e2e8f0; background:#fff; border-radius:20px; cursor:pointer;
          font-size:13px; font-weight:600; color:#64748b; transition:all .15s; }
.th-tab:hover { border-color:#93c5fd; }
.th-tab.active { background:#2563eb; color:#fff; border-color:#2563eb; }
.th-list { display:flex; flex-direction:column; gap:10px; }
.th-card { display:flex; gap:12px; align-items:flex-start; background:#fff; border:1px solid #e2e8f0;
           border-radius:12px; padding:12px 14px; }

/* ── PATRON ekranları ──────────────────────────────────────────────────────── */
.pt-cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(210px,1fr)); gap:12px; }
.pt-card, .pt-seg, .pt-total-card { background:#fff; border:1px solid #e2e8f0; border-radius:12px; padding:14px 16px; }
.pt-lbl { display:block; font-size:11px; color:#94a3b8; text-transform:uppercase; letter-spacing:.5px; margin-bottom:4px; }
.pt-val { display:block; font-size:22px; font-weight:700; line-height:1.2; }
.pt-card small, .pt-seg small, .pt-total-card small { display:block; margin-top:4px; font-size:12px; color:#94a3b8; }
.pt-verdict { display:flex; justify-content:space-between; align-items:center; gap:16px; flex-wrap:wrap;
              margin-top:12px; border:1px solid; border-radius:12px; padding:14px 18px; }
.pt-total-card { margin-bottom:12px; }
.pt-total { display:block; font-size:30px; font-weight:800; color:#2563eb; line-height:1.15; }
.pt-segs { display:grid; grid-template-columns:repeat(auto-fit,minmax(230px,1fr)); gap:12px; }
.pt-seg { cursor:pointer; transition:border-color .15s, box-shadow .15s; }
.pt-seg:hover { border-color:#93c5fd; }
.pt-seg.sel { border-color:#2563eb; box-shadow:0 0 0 2px #2563eb22; }
.pt-chips { display:flex; flex-wrap:wrap; gap:8px; margin-top:12px; }
.pt-chip { padding:6px 13px; border:1px solid #e2e8f0; background:#fff; border-radius:20px; cursor:pointer;
           font-size:13px; font-weight:600; color:#475569; }
.pt-chip:hover { border-color:#93c5fd; }
.pt-chip.sel { background:#2563eb; color:#fff; border-color:#2563eb; }
.pt-crumbs { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:10px; font-size:13px; }
.pt-crumb { cursor:pointer; color:#2563eb; font-weight:600; }
.pt-crumb:hover { text-decoration:underline; }
.pt-crumb.active { color:#1e293b; cursor:default; text-decoration:none; }
.pt-crumb-sep { color:#cbd5e1; }
@media (max-width:820px) { .pt-val { font-size:19px; } .pt-total { font-size:24px; } }

/* PATRON — Ödeme Takvimi (P3) */
.pt3-bar { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; margin-bottom:12px; }
.pt3-modes { display:flex; gap:6px; flex-wrap:wrap; }
.pt3-range { display:flex; gap:6px; align-items:center; flex-wrap:wrap; }
.pt3-range .input { width:150px; }
.pt3-legend { display:flex; gap:16px; flex-wrap:wrap; margin-top:10px; font-size:12px; color:#64748b; }
.pt3-legend i { display:inline-block; width:12px; height:12px; border-radius:3px; border:1px solid; margin-right:5px; vertical-align:-2px; }
@media (max-width:560px){ .pt3-range .input { width:calc(50% - 12px); } }

/* PATRON — Risk Limiti (P4) */
.pt4-h { margin:0 0 4px; font-size:15px; color:#1e293b; }
.pt4-sub { margin:0 0 10px; font-size:12px; color:#94a3b8; }
.pt4-warn { background:#fffbeb; border:1px solid #fde68a; color:#92400e; border-radius:8px;
            padding:9px 12px; font-size:12px; margin-bottom:10px; }

/* PATRON — Ana Sermaye (P5) */
.pt5-tbl { width:100%; border-collapse:collapse; }
.pt5-tbl td { padding:9px 4px; border-bottom:1px solid #f1f5f9; font-size:14px; vertical-align:top; }
.pt5-warn { font-size:11px; color:#b45309; margin-top:3px; }

/* Müşteri — toplu segment atama çubuğu */
.cust-bulk-bar { display:flex; align-items:center; gap:10px; flex-wrap:wrap; background:#eff6ff;
                 border:1px solid #bfdbfe; border-radius:10px; padding:10px 14px; margin-bottom:10px; font-size:13px; }


/* ═══════════ MOBİL 2 — tablo→kart · katlanır filtre · 44px dokunma ═══════════
   Hepsi media query içinde: geniş ekran görünümü değişmez.                    */
.filter-toggle { display: none; }

@media (max-width: 820px) {
  /* Dokunma hedefleri: parmakla rahat basılsın (44px yaygın kabul edilen alt sınır) */
  .btn, input.input, select.input, textarea.input { min-height: 44px; }
  .btn-sm, .btn-price-pick { min-height: 36px; }
  .input, select, textarea { font-size: 16px; }   /* iOS'ta odaklanınca yakınlaştırmayı engeller */
  .nav-link { padding-top: 13px; padding-bottom: 13px; }
  th, td { line-height: 1.35; }

  /* Katlanır filtre kartı: ekranın yarısını filtreler yemesin */
  .filter-card { padding: 10px 12px; }
  .filter-card > .filter-toggle {
    display: flex; width: 100%; align-items: center; justify-content: space-between;
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px;
    padding: 11px 14px; font-size: 14.5px; font-weight: 700; color: #334155;
    min-height: 44px; cursor: pointer;
  }
  .filter-card.kapali > *:not(.filter-toggle) { display: none; }
  .filter-card:not(.kapali) > .filter-toggle { margin-bottom: 10px; }
}

@media (max-width: 700px) {
  /* Geniş tablolar kart olur: her hücre "başlık → değer" satırı.
     data-label değerini app.js'teki _mobilTabloEtiketle() başlıktan üretir. */
  table.kart-mobil thead { display: none; }
  table.kart-mobil, table.kart-mobil tbody, table.kart-mobil tr, table.kart-mobil td { display: block; width: auto; }
  table.kart-mobil tr {
    border: 1px solid #e6ebf2; border-radius: 12px; margin: 0 0 10px;
    padding: 10px 12px; background: #fff; box-shadow: 0 1px 2px rgba(15,23,42,.04);
  }
  table.kart-mobil td {
    border: 0 !important; display: block; position: relative;
    padding: 5px 0 5px 41%; text-align: right; font-size: 13.5px; min-height: 22px;
    /* Masaüstü kolon kısıtları (satır içi max-width dahil) kart modunda geçersiz */
    max-width: none !important; min-width: 0 !important; width: auto !important;
    white-space: normal !important; overflow: visible !important; text-overflow: clip !important;
  }
  table.kart-mobil td > * { max-width: 100%; }
  /* Etiket mutlak konumlanır: hücrenin içeriği (tutar + "A" + alt açıklama)
     bölünmez, uzun açıklama alt satıra sarar. */
  table.kart-mobil td::before {
    content: attr(data-label); position: absolute; left: 0; top: 5px; width: 39%;
    color: #64748b; font-weight: 600; font-size: 12px; text-align: left;
    white-space: normal; line-height: 1.3;
  }
  /* Satır bir sütun yığını olur; başlık ve seçim kutusu order ile üste çıkar */
  table.kart-mobil tr { display: flex; flex-direction: column; }
  table.kart-mobil td.kart-secim {
    order: -2; padding: 0 0 4px; margin: 0; text-align: left; font-size: 13.5px;
    border: 0 !important;
  }
  table.kart-mobil td.kart-baslik {
    order: -1; font-weight: 700; font-size: 15px; color: #0f172a; text-align: left;
    padding: 0 0 8px; margin-bottom: 4px; border-bottom: 1px dashed #eef2f7 !important;
  }
  table.kart-mobil td.kart-baslik::before, table.kart-mobil td.kart-secim::before { display: none; }
  /* Kart başlığındaki alt bilgi (ör. "545 fatura") ikinci satıra iner */
  table.kart-mobil td.kart-baslik > div,
  table.kart-mobil td.kart-baslik > small {
    display: block; font-weight: 500; font-size: 12px; color: #94a3b8; margin-top: 2px;
  }
  table.kart-mobil td:empty,
  table.kart-mobil td.bos-mobil { display: none; }
  /* Firma detayındayken her kartta firma adını tekrarlamak 3 satır yiyor */
  #cari-detail-view table.kart-mobil td[data-label="Firma"],
  #ted-detay-view  table.kart-mobil td[data-label="Firma"] { display: none; }
  table.kart-mobil .table-empty, table.kart-mobil td[colspan] { justify-content: center; }
  table.kart-mobil td[colspan]::before { display: none; }
  /* Kart görünümünde yatay kaydırma gerekmez */
  .table-wrapper:has(table.kart-mobil) { overflow-x: visible; }
}


/* Denetim izi özet kutuları */
.den-ozet { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
            gap: 12px; margin-bottom: 12px; }
.den-ozet .stat-card { padding: 16px 18px; }
.den-ozet .stat-value { font-size: 24px; }
.stat-sub { font-size: 12px; color: #94a3b8; margin-top: 2px; }

/* Denetim izi işlem rozeti */
.den-badge { display:inline-block; padding:3px 10px; border-radius:999px;
             font-size:12px; font-weight:700; letter-spacing:.2px; }


/* ── Belgeler (fiş/fatura fotoğrafı) ──────────────────────────────────────── */
.belge-yukle { display:flex; align-items:center; gap:12px; margin-bottom:14px; flex-wrap:wrap; }
.belge-liste { display:flex; flex-direction:column; gap:10px; }
.belge-kart  { display:flex; align-items:center; gap:12px; border:1px solid #eef2f7;
               border-radius:10px; padding:8px 10px; background:#fff; }
.belge-onizleme { flex:0 0 64px; height:64px; border-radius:8px; overflow:hidden;
                  background:#f1f5f9; display:flex; align-items:center; justify-content:center; }
.belge-onizleme img { width:100%; height:100%; object-fit:cover; }
.belge-pdf   { font-weight:800; font-size:13px; color:#dc2626; }
.belge-bilgi { flex:1 1 auto; min-width:0; }
.belge-ad    { font-weight:600; font-size:14px; color:#0f172a; overflow:hidden;
               text-overflow:ellipsis; white-space:nowrap; }
.belge-meta  { font-size:12px; color:#94a3b8; margin-top:2px; }


/* ── Modal genişliği ──────────────────────────────────────────────────────────
   .modal'ın sabit width'i var; geniş modal ayrı sınıfla verilir. Tablolu
   modallar (alış geçmişi, belgeler, denetim detayı) buna ihtiyaç duyuyor. */
/* Geniş modal içeriğine göre büyür: tablolu modal 1000px'e kadar açılır, kısa
   içerikli modal (belge listesi gibi) 560px'te kalır — boş boşluk oluşmaz. */
.modal.genis {
  width: fit-content;
  min-width: min(560px, 100%);
  max-width: min(1080px, 96vw);
}
.tablo-kaydir-ipucu { font-size: 12px; color: #94a3b8; padding: 6px 2px 0; }

@media (max-width: 820px) {
  .modal.genis { width: 100%; }
}
@media (max-width: 700px) {
  /* Telefonda modal neredeyse tam ekran: içerik sıkışmasın */
  .modal, .modal.genis { width: 100%; max-height: 94vh; }
  .modal-body { padding: 14px 12px; }
  .modal-header { padding: 14px 14px; }
  /* Modal içindeki tablo da karta döner (app.js etiketleri modal için de yazar) */
  .modal-body .table-wrapper { overflow-x: auto; }
  .modal-body table.kart-mobil tr { margin-bottom: 8px; }
}
