:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand {
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar .brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary);
  display: inline-block;
}

.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.nav a {
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
}

.nav a.active, .nav a:hover {
  background: #eef2ff;
  color: var(--primary);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--muted);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.container.narrow {
  max-width: 420px;
  padding-top: 60px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card + .card { margin-top: 16px; }

h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
.subtitle { color: var(--muted); font-size: 0.92rem; margin: 0 0 20px; }

.grid {
  display: grid;
  gap: 16px;
}
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: 0.82rem; margin-bottom: 6px; }
.stat .value { font-size: 1.6rem; font-weight: 700; }
.stat .value.small { font-size: 1.25rem; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin: 12px 0 6px;
}
label:first-child { margin-top: 0; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.secondary { background: #eef2ff; color: var(--primary); }
.btn.secondary:hover { background: #e0e7ff; }
.btn.danger { background: #fee2e2; color: var(--danger); }
.btn.danger:hover { background: #fecaca; }
.btn.success { background: var(--success); }
.btn.sm { padding: 6px 10px; font-size: 0.8rem; }

.msg {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 14px;
}
.msg.error { background: #fee2e2; color: #991b1b; }
.msg.success { background: #dcfce7; color: #14532d; }
.msg.info { background: #e0f2fe; color: #075985; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.admin { background: #ede9fe; color: #5b21b6; }
.badge.personel { background: #dbeafe; color: #1e40af; }
.badge.low-stock { background: #fef3c7; color: #92400e; }
.badge.ok-stock { background: #dcfce7; color: #14532d; }
.badge.danger { background: #fee2e2; color: #991b1b; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.barcode-label {
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  background: #fff;
}
.barcode-label .name { font-weight: 700; font-size: 0.85rem; margin-bottom: 4px; }
.barcode-label .price { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

#scan-video {
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius);
  background: #000;
}

.product-hit {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: #fff;
}
.product-hit .pname { font-size: 1.15rem; font-weight: 700; }
.product-hit .pprice { font-size: 1.4rem; font-weight: 800; color: var(--primary); margin: 6px 0; }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 30px 10px;
  font-size: 0.9rem;
}

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}

/* ============ Alt sekme cubugu (bottom tab bar) - sadece mobilde ============ */
.bottom-nav { display: none; }

/* ============ Mobil (telefon) duzenlemeleri ============ */
@media (max-width: 768px) {
  html { -webkit-text-size-adjust: 100%; }

  body {
    padding-bottom: calc(66px + env(safe-area-inset-bottom));
  }

  .container { padding: 14px 12px 32px; }
  .container.narrow { padding-top: 40px; }

  .topbar { padding: 10px 14px; }
  .topbar .nav { display: none; }
  .topbar .user-chip-name { display: none; }
  .topbar .brand { font-size: 1rem; }

  h1 { font-size: 1.3rem; }

  .card { padding: 16px; }

  /* Dokunma hedeflerini buyut, iOS'ta input'a odaklaninca otomatik yakinlastirmayi engelle (16px sarti) */
  input, select, textarea {
    font-size: 16px;
    padding: 12px 12px;
  }
  .btn {
    min-height: 44px;
    padding: 11px 16px;
  }
  .btn.sm { min-height: 38px; padding: 8px 12px; }

  .row { gap: 8px; }

  /* Genis tablolari (cok sutunlu) kart goruntusune cevir */
  .table-wrap.stack-mobile table,
  .table-wrap.stack-mobile thead,
  .table-wrap.stack-mobile tbody,
  .table-wrap.stack-mobile th,
  .table-wrap.stack-mobile tr {
    display: block;
    width: 100%;
  }
  .table-wrap.stack-mobile thead { display: none; }
  .table-wrap.stack-mobile tr {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px 12px;
    margin-bottom: 10px;
    background: #fff;
  }
  .table-wrap.stack-mobile tr:last-child { margin-bottom: 0; }
  .table-wrap.stack-mobile td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px dashed var(--border);
    text-align: right;
  }
  .table-wrap.stack-mobile td:last-child { border-bottom: none; }
  .table-wrap.stack-mobile td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: left;
    flex-shrink: 0;
  }
  .table-wrap.stack-mobile td[data-label=""]::before,
  .table-wrap.stack-mobile td:not([data-label])::before { display: none; }
  .table-wrap.stack-mobile td > * { margin-left: auto; }
  /* Etiketsiz (islem butonlari) hucrelerde birden fazla buton varsa sagda grup halinde dursun */
  .table-wrap.stack-mobile td[data-label=""] {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
  }
  .table-wrap.stack-mobile td[data-label=""] > * { margin-left: 0; }

  #scan-video { max-width: 100%; }
}

/* Cok kucuk ekranlar (kucuk telefonlar) */
@media (max-width: 380px) {
  .bottom-nav a .bn-label { font-size: 0.62rem; }
  .stat .value { font-size: 1.35rem; }
}

@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 30;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
  }
  .bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 600;
    padding: 6px 2px;
    border-radius: 10px;
    min-height: 44px;
  }
  .bottom-nav a .bn-icon { font-size: 1.3rem; line-height: 1; }
  .bottom-nav a.active { color: var(--primary); background: #eef2ff; }
}
