: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(8),
body.role-satisci #page-sales tbody td:nth-child(8),
body.role-satisci #page-sales thead th:nth-child(10),
body.role-satisci #page-sales tbody td:nth-child(10),
body.role-satisci #page-sales thead th:nth-child(11),
body.role-satisci #page-sales tbody td:nth-child(11) { display: none; }
body.role-satisci #page-sales tfoot { display: none; }
.nav-links { overflow-x: auto; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }
