/* =============================================================================
   Sipariş Hattı — panel arayüzü
   Açık ve koyu tema, tek renk paleti üzerinden.
   ========================================================================== */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --ink: #131a23;
  --muted: #5b6775;
  --line: #dce2ea;
  --accent: #1b44c8;
  --accent-ink: #ffffff;
  --accent-soft: #e7ecfb;
  --ok: #145c3d;
  --ok-soft: #e3f1ea;
  --warn: #9a5209;
  --warn-soft: #faefe0;
  --danger: #a11d1d;
  --danger-soft: #fbe9e9;
  --shadow: 0 1px 2px rgba(18, 26, 35, .06), 0 8px 24px -18px rgba(18, 26, 35, .3);

  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --r: 10px;
  --sidebar: 240px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1318;
    --surface: #161d25;
    --surface-2: #1c242e;
    --ink: #e5eaef;
    --muted: #939eac;
    --line: #263039;
    --accent: #8aa5ff;
    --accent-ink: #0e1318;
    --accent-soft: #19233c;
    --ok: #5cc79b;
    --ok-soft: #14261e;
    --warn: #e2a45c;
    --warn-soft: #2a2015;
    --danger: #f08a8a;
    --danger-soft: #2b1717;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -18px rgba(0,0,0,.9);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;   /* sayfa hiçbir koşulda yana kaymasın */
}

/* ---------------------------------------------------------------- giriş --- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

/* Arka planda çok hafif bir ışık — düz beyazlığı kırıyor */
.login-wrap::before {
  content: "";
  position: absolute;
  inset: -30% 20% auto;
  height: 70vh;
  background: radial-gradient(ellipse at 50% 0%, var(--accent-soft), transparent 68%);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 388px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(18,26,35,.05), 0 24px 60px -30px rgba(18,26,35,.45);
  padding: 34px 32px 30px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-card h1 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -.025em;
}

.login-card .sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* Giriş kartının altındaki ikincil bağlantılar — kaydol, şifremi unuttum */
.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13.5px;
}
.auth-links a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.auth-links a:hover { border-bottom-color: currentColor; }
.auth-links a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

/* Kurulum kontrol listesi — yeni firmayı ilk gönderime kadar götürür */
.setup-step {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 10px 8px; border-radius: 9px;
  color: inherit; text-decoration: none;
}
.setup-step:hover { background: var(--surface-2); }
.setup-step:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.setup-tick {
  flex: none; width: 20px; height: 20px; margin-top: 1px;
  border: 1.5px solid var(--line); border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; line-height: 1;
}
.setup-step.done .setup-tick {
  background: var(--ok); border-color: var(--ok); color: #fff;
}
.setup-step.done .setup-name { color: var(--muted); text-decoration: line-through; }

/* Bilgi ekranı: "e-postanı kontrol et" */
.auth-icon {
  width: 46px; height: 46px; border-radius: 13px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 22px;
}

.brand-row { display: flex; align-items: center; gap: 10px; }

.logo { display: block; color: var(--accent); }
.logo svg { display: block; width: 34px; height: 34px; border-radius: 9px; }
.logo.sm svg { width: 30px; height: 30px; border-radius: 8px; }

.brand {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* --------------------------------------------------------------- düzen --- */

.app { display: none; min-height: 100vh; }
.app.on { display: grid; grid-template-columns: var(--sidebar) 1fr; }

aside {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.side-head { display: flex; align-items: center; gap: 10px; padding: 2px 8px; }
.side-head-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.side-head strong {
  font-size: 15.5px;
  letter-spacing: -.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-head span { font-size: 12.5px; color: var(--muted); }

nav { display: flex; flex-direction: column; gap: 2px; }

nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14.5px;
}

nav a svg {
  width: 19px;
  height: 19px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .75;
}

nav a:hover { background: var(--surface-2); }
nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
nav a.active svg { opacity: 1; }

nav a .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 20px;
  background: var(--warn-soft);
  color: var(--warn);
}

/* Dil seçici: giriş ekranında sağ üst köşe, panelde menünün üstü */
.lang-corner {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  z-index: 2;
}
.lang-corner select {
  width: auto;
  padding: 8px 30px 8px 12px;
  font-size: 14px;
  background-color: var(--surface);
  border-color: var(--line);
  box-shadow: 0 1px 2px rgba(18,26,35,.05);
}
.side-lang { padding: 0 8px 2px; }
.side-lang select { width: 100%; padding: 8px 30px 8px 10px; font-size: 14px; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

main { padding: 28px 32px 64px; min-width: 0; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}

.page-head h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); font-size: 14px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ------------------------------------------------------------- bileşen --- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 16px; }
.card-pad { padding: 18px 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }

.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 15px 16px 14px;
  overflow: hidden;
  transition: border-color .15s ease, transform .15s ease;
}

/* Üstte ince renkli şerit — kutuyu sayfadan ayırıyor */
.stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--accent);
  opacity: .55;
}

.stat:hover { border-color: var(--accent); transform: translateY(-1px); }
.stat.warn::before { background: var(--warn); }
.stat.ok::before { background: var(--ok); }

.stat-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-size: 25px; font-weight: 650; letter-spacing: -.025em; font-variant-numeric: tabular-nums; margin-top: 2px; }

label { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; color: var(--muted); }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  width: 100%;
}

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

textarea { min-height: 72px; resize: vertical; }

.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

button {
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 14px;
  transition: background .13s ease, border-color .13s ease, transform .08s ease, filter .13s ease;
}

button:hover { background: var(--surface-2); border-color: var(--muted); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; transform: none; }
button:disabled:hover { background: var(--surface); border-color: var(--line); }

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(18,26,35,.16);
}
button.primary:hover { filter: brightness(1.09); border-color: transparent; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: var(--surface-2); color: var(--ink); }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.danger:hover { background: var(--danger-soft); }
button.sm { padding: 5px 9px; font-size: 13px; }

/* -------------------------------------------------------------- tablo --- */

.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }

th {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

tbody tr { transition: background .12s ease; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
td.actions { text-align: right; white-space: nowrap; }

/* Satır üstünde değilken işlem düğmeleri geri çekilsin — liste sakin görünsün */
td.actions button { opacity: .55; transition: opacity .12s ease; }
tr:hover td.actions button,
td.actions button:focus-visible { opacity: 1; }

.pill {
  display: inline-block;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-off { background: var(--surface-2); color: var(--muted); }
.pill-day { background: var(--accent-soft); color: var(--accent); font-family: var(--mono); font-size: 11px; }

.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14.5px;
}

/* Bekleme durumu: yazı yerine hareketli çizgi — sayfa donmuş gibi görünmesin */
.skeleton {
  height: 46px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface) 50%, var(--surface-2) 75%);
  background-size: 300% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}

.skeleton + .skeleton { margin-top: 8px; }

@keyframes shimmer {
  from { background-position: 150% 0; }
  to   { background-position: -50% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  * { transition-duration: .01ms !important; }
}

input, select, textarea { transition: border-color .13s ease, box-shadow .13s ease; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

nav a { transition: background .12s ease, color .12s ease; }

/* ------------------------------------------------------------- modal --- */

dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  box-shadow: 0 24px 64px -24px rgba(0,0,0,.5);
}

dialog::backdrop { background: rgba(10, 14, 20, .45); }

.modal-head { padding: 18px 20px 0; }
.modal-head h3 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 14px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------ bildirim --- */

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: 8px;
  padding: 11px 15px;
  box-shadow: var(--shadow);
  font-size: 14px;
  max-width: 340px;
}

.toast.err { border-left-color: var(--danger); }

.hint { font-size: 13px; color: var(--muted); }
.err-text { color: var(--danger); font-size: 13.5px; }
.hidden { display: none !important; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.check input { width: auto; }

/* =============================================================================
   TELEFON — uygulama gibi kullanım
   Tablolar karta dönüşür, gezinme alta sabitlenir, kipler alttan açılır.
   ========================================================================== */

@media (max-width: 820px) {

  /* iOS'ta alana dokununca sayfayı yakınlaştırmasın diye 16px şart */
  input, select, textarea { font-size: 16px; padding: 11px 12px; }

  button { padding: 11px 15px; }
  button.sm { padding: 8px 12px; font-size: 14px; }

  .app.on { grid-template-columns: 1fr; }

  /* Üst başlık: firma adı + dil + çıkış */
  aside {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
    border-right: none;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }

  .side-head { flex: 1; min-width: 0; padding: 0; }
  .side-head strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-head span { display: none; }

  /* Telefonda dil seçici üst çubukta, çıkışın yanında durur */
  .side-lang { padding: 0; order: 2; }
  .side-lang select { width: auto; padding: 8px 26px 8px 10px; font-size: 14px; }

  .side-foot { margin-top: 0; order: 3; flex-direction: row; align-items: center; gap: 8px; }
  .side-foot button { padding: 8px 12px; font-size: 14px; }

  /* Gezinme: alt sekme çubuğu */
  nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    flex-direction: row;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 6px 4px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    gap: 0;
  }

  nav a {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px;
    border-radius: 10px;
    font-size: 10.5px;
    line-height: 1.2;
    text-align: center;
    position: relative;
  }

  nav a svg { width: 22px; height: 22px; opacity: .65; }

  nav a span:not(.count) {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  nav a.active { background: transparent; }
  nav a.active svg { opacity: 1; }

  /* Rozet: sekmenin sağ üstünde */
  nav a .count {
    position: absolute;
    top: 2px;
    left: 50%;
    margin-left: 6px;
    font-size: 10px;
    padding: 0 5px;
    line-height: 16px;
  }

  main { padding: 16px 14px calc(84px + env(safe-area-inset-bottom)); }

  .page-head { margin-bottom: 16px; }
  .page-head h2 { font-size: 20px; }
  .head-actions { width: 100%; }
  /* İkişerli sarsın, üçü yan yana sıkışmasın */
  .head-actions button { flex: 1 1 45%; min-width: 0; white-space: nowrap; }

  .side-foot select, .side-foot button { flex: none; }
  .stat { min-width: 0; }
  .card, .card-pad { min-width: 0; }

  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 21px; }

  .card-pad { padding: 16px; }
  .field-row { grid-template-columns: 1fr; }

  /* ---- Tablo → kart ---- */
  .table-scroll { overflow-x: visible; }

  /* Masaüstü için konan asgari genişlik burada geçerli olmamalı,
     yoksa sayfa telefonda yana taşar. */
  table, tbody, tr, td { display: block; width: 100%; min-width: 0; }
  thead { display: none; }

  tbody tr {
    border: 1px solid var(--line);
    border-radius: 12px;
    margin: 0 0 10px;
    padding: 4px 0;
    background: var(--surface);
  }

  tbody tr:hover { background: var(--surface); }

  td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border: none;
    padding: 8px 14px;
    text-align: right;
  }

  td::before {
    content: attr(data-label);
    flex: none;
    font-family: var(--mono);
    font-size: 10.5px;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: left;
  }

  /* Etiketi olmayan hücrelerde boşluk bırakma */
  td:not([data-label])::before { content: none; }

  td.num { text-align: right; }

  td.actions {
    justify-content: flex-end;
    gap: 8px;
    padding-top: 10px;
    margin-top: 2px;
    border-top: 1px solid var(--line);
  }

  td.actions button { flex: 1; }

  /* ---- Kip → alttan açılan sayfa ---- */
  dialog {
    width: 100%;
    max-width: none;
    margin: 0;
    margin-top: auto;
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
  }

  .modal-body { max-height: 65vh; overflow-y: auto; }
  .modal-foot { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .modal-foot button { flex: 1; }

  #toast { left: 14px; right: 14px; bottom: calc(84px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
}

/* Çok dar telefonlar: sekme yazılarını gizle, sadece simge kalsın */
@media (max-width: 380px) {
  nav a span:not(.count) { display: none; }
  nav a { padding: 10px 2px; }
  nav a svg { width: 24px; height: 24px; }
}

/* Ana ekrandan açıldığında (uygulama modu) üst çentik payı */
@media (display-mode: standalone) {
  aside { padding-top: max(14px, env(safe-area-inset-top)); }
}

/* Aktarım listesinde satır içi düzenleme.
   Alanlar düz metin gibi durur, dokununca giriş alanına dönüşür — 300 kişilik
   listede her satıra çerçeveli kutu koymak okunmaz hâle getiriyordu. */
.imp-edit {
  width: 100%; font: inherit; color: var(--ink);
  background: transparent; border: 1px solid transparent;
  border-radius: 6px; padding: 3px 5px;
}
.imp-edit::placeholder { color: var(--muted); font-style: italic; }
.imp-edit:hover { border-color: var(--line); }
.imp-edit:focus { border-color: var(--accent); background: var(--surface); outline: none; }
.imp-edit.imp-name { font-weight: 600; }
.imp-edit.imp-comp { font-size: 13px; color: var(--muted); }
