/* ===== Temel ===== */
:root {
  --primary: #6d2d6d;
  --primary-dark: #4a1f4a;
  --accent: #b97135;
  --bg: #f5f6f4;
  --bg-card: #ffffff;
  --text: #1f2937;
  --text-mute: #6b7280;
  --border: #e5e7eb;
  --error: #b91c1c;
  --success: #15803d;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

.view { display: none; min-height: 100dvh; padding: 0 16px 32px; }
.view.active { display: block; }

.card {
  background: var(--bg-card);
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 14px 16px;
  margin: 12px 0;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  border: none; border-radius: 12px;
  padding: 12px 18px;
  font-size: 16px; font-weight: 600;
  cursor: pointer;
  transition: transform .05s, background .15s, opacity .15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: progress; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn.big { padding: 14px 22px; font-size: 17px; width: 100%; }
.btn.huge {
  padding: 28px 22px;
  font-size: 22px;
  font-weight: 700;
  width: 100%;
  margin: 16px 0;
  background: var(--primary);
  color: #fff;
  border-radius: 18px;
  box-shadow: 0 6px 16px rgba(109,45,109, 0.25);
}
.btn.huge:hover { background: var(--primary-dark); }
.btn .cam-icon { font-size: 28px; }

.icon-btn {
  background: transparent; border: none;
  font-size: 22px; cursor: pointer;
  width: 40px; height: 40px;
  border-radius: 8px; color: var(--text);
}
.icon-btn:active { background: rgba(0,0,0,0.05); }

.link-btn {
  background: transparent; border: none;
  color: var(--primary); font-size: 13px;
  cursor: pointer; padding: 0; text-decoration: underline;
}

/* ===== Giriş ekranı ===== */
.brand {
  display: flex; align-items: center; gap: 14px;
  padding: 44px 16px 24px;
}
.brand-logo {
  width: 56px; height: 56px;
  background: var(--primary); color: #fff;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800;
  letter-spacing: -0.02em;
}
.brand h1 {
  margin: 0;
  font-size: 24px; font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.05;
}
.brand h1 span {
  font-size: 14px; font-weight: 500;
  color: var(--text-mute);
}

/* Giriş sayfaları: logo kutusu + büyük başlık (index + uretici ortak) */
.login-logobox {
  border: 1px solid var(--primary); border-radius: 14px; background: #fff;
  padding: 14px 12px; text-align: center;
  max-width: 360px; margin: 32px auto 12px;
}
.login-logobox img { width: 210px; max-width: 80%; height: auto; display: block; margin: 0 auto; }
.login-title {
  text-align: center; font-size: 28px; font-weight: 700;
  color: var(--primary-dark); margin: 6px 0 18px;
}
.login-altbtn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  max-width: 360px; margin: 14px auto 0; min-height: 46px; padding: 12px 14px;
  border: 1px solid var(--primary); background: #f2e8f2; color: var(--primary);
  border-radius: 10px; font-size: 15px; font-weight: 600; text-decoration: none;
}
.login-altbtn:active { transform: scale(0.99); }
/* Personel giriş sütununu üretici (u-wrap ~520) genişliğine daralt/ortala */
#view-login .card { max-width: 520px; margin: 12px auto; }
#view-login .login-altbtn { max-width: 520px; }

/* Tarayıcı ana ekran üst barı (⋮ yerine görünür butonlar) */
.home-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0 8px; flex-wrap: wrap;
}
.home-head .hh-logo {
  width: 38px; height: 38px; border-radius: 9px; flex: 0 0 38px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px;
}
.home-head .hh-who { margin-right: 4px; }
.home-head .hh-who .hello { font-size: 11px; color: var(--text-mute); line-height: 1; }
.home-head .hh-who .username { font-size: 16px; font-weight: 700; color: var(--primary-dark); }
.home-head .hh-nav {
  font-size: 13px; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; color: var(--primary);
  cursor: pointer; text-decoration: none;
}
.home-head .hh-nav:hover { border-color: var(--primary); }
.home-head .hh-cikis {
  margin-left: auto;
  font-size: 13px; padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; color: var(--error);
  font-weight: 600; cursor: pointer;
}
.home-head .hh-cikis:hover { border-color: var(--error); }

/* Masaüstünde tarayıcı sayfasını ortala/daralt (admin & üretici hesapları hariç) */
@media (min-width: 620px) {
  #view-home, #view-send, #view-cari { max-width: 560px; margin-left: auto; margin-right: auto; }
}

.form { display: flex; flex-direction: column; gap: 14px; }
.form label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 13px; color: var(--text-mute);
}
.form input, .form select, .netkg-label input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.form input:focus, .netkg-label input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(109,45,109,0.12);
}
.err { color: var(--error); font-size: 13px; margin: 0; min-height: 18px; }

/* ===== Ana ekran ===== */
.topbar {
  display: flex; align-items: center;
  padding: 14px 0 4px;
  gap: 12px;
}
.topbar .hello { font-size: 12px; color: var(--text-mute); }
.topbar .username { font-size: 17px; font-weight: 700; }
.topbar > div:first-child { flex: 1; }
.topbar .title { flex: 1; text-align: center; font-weight: 700; font-size: 17px; }

.koy-card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.koy-label { font-size: 12px; color: var(--text-mute); }
.koy-value {
  font-size: 22px; font-weight: 700;
  color: var(--primary-dark); flex: 1;
}

.date-card .date-label { font-size: 12px; color: var(--text-mute); }
.date-card .date-value { font-size: 16px; font-weight: 600; }

.history-card { padding-bottom: 6px; }
.history-head {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 13px; color: var(--text-mute); margin-bottom: 6px;
}
.history-count {
  font-weight: 700; color: var(--primary);
  background: #f2e8f2; padding: 2px 8px; border-radius: 99px;
}
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-list .empty {
  padding: 14px 4px; text-align: center; color: var(--text-mute); font-size: 13px;
}
.h-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 4px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
}
.h-item:first-child { border-top: none; }
.h-item .h-koy { font-weight: 600; }
.h-item .h-meta { color: var(--text-mute); font-size: 12px; }
.h-item .h-kg { font-weight: 700; color: var(--primary-dark); }

/* ===== Gönder ekranı ===== */
.preview-wrap {
  background: #000;
  border-radius: 12px;
  margin: 12px 0;
  overflow: hidden;
  aspect-ratio: 3/4;
  display: flex; align-items: center; justify-content: center;
}
#previewImg { max-width: 100%; max-height: 100%; display: block; }

.row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 0; border-top: 1px solid var(--border); font-size: 14px;
}
.row:first-child { border-top: none; }
.row-key { color: var(--text-mute); }
.row-val { font-weight: 600; text-align: right; }

.netkg-label {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 10px;
  font-size: 13px; color: var(--text-mute);
}
.netkg-label input {
  font-size: 22px; font-weight: 600; text-align: center; padding: 14px;
}

.actions { display: flex; gap: 10px; margin: 14px 0 0; }
.actions .btn { flex: 1; }

.send-status {
  margin-top: 14px; padding: 12px 14px;
  border-radius: 10px; font-size: 14px;
  display: none;
}
.send-status.ok { display: block; background: #ecfdf5; color: var(--success); border: 1px solid #a7f3d0; }
.send-status.err { display: block; background: #fef2f2; color: var(--error); border: 1px solid #fecaca; }
.send-status.busy { display: block; background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ===== Modal ===== */
.modal, .menu {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
}
.modal[hidden], .menu[hidden] { display: none !important; }
.modal-card, .menu-card {
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 16px;
  width: 100%; max-width: 480px;
  max-height: 85vh; overflow-y: auto;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
}
@media (min-width: 600px) {
  .modal, .menu { align-items: center; }
  .modal-card, .menu-card { border-radius: 16px; }
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; }

.koy-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.koy-list button {
  background: #fff; border: 1px solid var(--border);
  padding: 14px 16px; border-radius: 10px;
  font-size: 16px; font-weight: 600; text-align: left;
  cursor: pointer;
}
.koy-list button:hover, .koy-list button.active {
  border-color: var(--primary); background: #f4ecf4; color: var(--primary-dark);
}

.menu-card { padding: 8px; }
.menu-item {
  display: block; width: 100%;
  background: #fff; border: none;
  padding: 14px 16px; font-size: 16px;
  text-align: left; cursor: pointer;
  border-radius: 10px; color: var(--text);
  text-decoration: none;
}
.menu-item:hover { background: #f3f4f6; }
.menu-item.danger { color: var(--error); }

/* ===== KAMERA EKRANI ===== */
.view-camera {
  padding: 0;
  background: #000;
  position: fixed; inset: 0;
  overflow: hidden;
  z-index: 50;
}
.view-camera.active { display: block; }

#camVideo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: #000;
}

/* Karanlık overlay; çerçeve içi temiz kalsın diye box-shadow ile delik açıyoruz */
.cam-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
}

.cam-frame {
  position: absolute;
  /* A4 oranı: width:height = 1 : 1.41 */
  /* width ne kadar büyük olabilir → ekran genişliğinin %88'i VEYA yüksekliğin %62'sinin A4 karşılığı */
  width: min(88vw, calc((62vh) / 1.41));
  aspect-ratio: 1 / 1.41;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255,255,255,0.35);
  /* dış karanlık alan */
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.55);
  border-radius: 2px;
}

/* 4 köşe bracket */
.cam-corner {
  position: absolute;
  width: 26px; height: 26px;
  border: 3px solid #fff;
}
.cam-corner.tl { top: -3px; left: -3px; border-right: none; border-bottom: none; border-top-left-radius: 4px; }
.cam-corner.tr { top: -3px; right: -3px; border-left: none; border-bottom: none; border-top-right-radius: 4px; }
.cam-corner.bl { bottom: -3px; left: -3px; border-right: none; border-top: none; border-bottom-left-radius: 4px; }
.cam-corner.br { bottom: -3px; right: -3px; border-left: none; border-top: none; border-bottom-right-radius: 4px; }

.cam-hint {
  position: absolute;
  left: 0; right: 0; bottom: -36px;
  text-align: center;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  letter-spacing: 0.01em;
}

.cam-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: env(safe-area-inset-top, 12px) 14px 0;
  display: flex; justify-content: space-between;
  z-index: 2;
}
.cam-icon-btn {
  color: #fff;
  background: rgba(0,0,0,0.4);
  width: 42px; height: 42px;
  border-radius: 50%;
  font-size: 18px;
  backdrop-filter: blur(4px);
}
.cam-icon-btn:active { background: rgba(0,0,0,0.6); }

.cam-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 20px 16px calc(28px + env(safe-area-inset-bottom, 0));
  display: flex; justify-content: center; align-items: center;
  z-index: 2;
}

.cam-shutter {
  width: 76px; height: 76px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  border: 4px solid #fff;
  cursor: pointer;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s;
}
.cam-shutter:active { transform: scale(0.92); }
.cam-shutter:disabled { opacity: 0.5; cursor: progress; }
.cam-shutter-inner {
  display: block;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: #fff;
}

.cam-error {
  position: absolute;
  left: 16px; right: 16px;
  top: 50%; transform: translateY(-50%);
  padding: 16px 18px;
  background: rgba(0,0,0,0.85);
  color: #fff;
  border-radius: 12px;
  font-size: 14px;
  z-index: 3;
  text-align: center;
  line-height: 1.5;
}
.cam-error b { color: #ffd166; }
.cam-error button {
  margin-top: 12px;
  padding: 10px 18px;
  background: #fff; color: #000;
  border: none; border-radius: 8px;
  font-weight: 600; cursor: pointer;
}

/* ===== PWA install rehberi ===== */
.install-card {
  max-width: 480px;
  padding: 20px 18px;
}
.install-intro {
  font-size: 13.5px;
  color: var(--text-mute);
  margin: 0 0 14px;
  line-height: 1.5;
}
.install-steps {
  margin: 12px 0;
  padding: 12px 14px;
  background: #f8faf7;
  border: 1px solid #e1ebe2;
  border-radius: 10px;
}
.install-platform {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 8px;
}
.install-steps ol {
  margin: 0; padding-left: 20px;
  font-size: 13.5px; line-height: 1.7;
}
.install-steps ol li b { color: var(--text); }
.install-steps p {
  margin: 8px 0 0; font-size: 12.5px; color: var(--text-mute);
}
.ios-share {
  display: inline-block; padding: 1px 6px;
  background: #007aff; color: #fff;
  border-radius: 4px; font-size: 12px;
}

.install-banner {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0));
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  z-index: 80;
  font-size: 13.5px;
  animation: slideUp .25s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.install-banner-icon { font-size: 20px; }
.install-banner-text { flex: 1; font-weight: 600; color: var(--text); }
.install-banner-btn {
  padding: 6px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: none;
}
.install-banner-btn.primary { background: var(--primary); color: #fff; }
.install-banner-btn.ghost {
  background: transparent; color: var(--text-mute);
  font-size: 16px; padding: 6px 8px;
}
.install-banner-btn.ghost:hover { color: var(--text); }

/* ===== Cari bakiye sorgu ===== */
.cari-hint { font-size: 12px; color: var(--text-mute); margin: 8px 2px 0; }
.cari-info { font-size: 14px; color: var(--text-mute); padding: 12px; text-align: center; }
.cari-summary { background: var(--primary); color: #fff; border: none; }
.cari-name { font-size: 17px; font-weight: 600; }
.cari-sub { font-size: 12px; opacity: .85; margin-top: 2px; }
.cari-bakiye-box {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.2);
}
.cari-bakiye-box span { font-size: 13px; opacity: .9; }
.cari-bakiye-box strong { font-size: 22px; font-weight: 600; }
.cari-tot-row { display: flex; gap: 10px; margin-top: 12px; }
.cari-tot { flex: 1; background: rgba(255,255,255,.14); border-radius: 8px; padding: 8px 10px; }
.cari-tot-l { font-size: 11px; opacity: .85; }
.cari-tot-v { font-size: 15px; font-weight: 500; margin-top: 2px; }
.cari-list-card { margin-top: 12px; padding-top: 6px; }
.cari-list-head { font-size: 13px; color: var(--text-mute); font-weight: 600; padding: 6px 2px 10px; }
.cari-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 2px; border-top: 1px solid var(--border);
}
.cari-row-ac { font-size: 14px; font-weight: 500; }
.cari-row-tar { font-size: 12px; color: var(--text-mute); margin-top: 2px; }
.cari-row-amt { font-size: 15px; font-weight: 600; white-space: nowrap; padding-left: 10px; }
.cari-row.alim .cari-row-amt { color: var(--success); }
.cari-row.odeme .cari-row-amt { color: var(--error); }
.cari-sug { display: flex; flex-direction: column; margin-top: 6px; }
.cari-sug-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left; background: #fff; border: none;
  border-bottom: 1px solid var(--border); padding: 12px 4px;
  font-size: 15px; font-family: inherit; cursor: pointer;
}
.cari-sug-item:active { background: #f4ecf4; }
.cari-sug-ad { font-weight: 600; }
.cari-sug-no { font-size: 12px; color: var(--text-mute); white-space: nowrap; }
.cari-sug-empty { padding: 12px 4px; font-size: 13px; color: var(--text-mute); }

/* ===== Genel yardımcılar ===== */
[hidden] { display: none !important; }

@media (max-width: 380px) {
  .btn.huge { font-size: 19px; padding: 22px; }
  .koy-value { font-size: 19px; }
}


/* ===== Merkezi tarama ===== */
#merkUrun, #merkTarih { width:100%; padding:10px; font-size:16px; border:1px solid #ccc; border-radius:10px; box-sizing:border-box; margin-top:4px; background:#fff; }
.merkezi-result { margin-top:14px; overflow-x:auto; }
.merk-tbl { width:100%; border-collapse:collapse; font-size:13px; }
.merk-tbl th, .merk-tbl td { border:1px solid rgba(0,0,0,.12); padding:5px 7px; text-align:left; }
.merk-tbl th { background:rgba(109,45,109,.10); }
.merk-ozet { margin:8px 0; padding:8px 10px; background:rgba(109,45,109,.10); border-radius:8px; font-weight:600; font-size:14px; }
