/* ============================================================
   Alen ERP — shadcn tarzı tasarım sistemi (saf CSS, bağımlılık yok)
   ============================================================ */

:root{
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --ring: 240 5% 65%;
  --destructive: 0 72% 51%;
  --radius: 0.5rem;

  --page-bg: 240 5% 96%;
}

*{ box-sizing: border-box; }

html{ -webkit-text-size-adjust: 100%; overflow-x: hidden; }

body{
  margin: 0;
  overflow-x: hidden;
  background: hsl(var(--page-bg));
  color: hsl(var(--foreground));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a{ color: inherit; text-decoration: none; }

h1,h2,h3,h4,h5{ margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1{ font-size: 1.5rem; }
h2{ font-size: 1.375rem; }
h3{ font-size: 1.125rem; }
p{ margin: 0; }

.icon{ width: 1rem; height: 1rem; flex: 0 0 auto; }
.icon-lg{ width: 1.25rem; height: 1.25rem; }

/* Sayılar ayrı font (ERP tarzı ayrışma, temiz sıfır) */
.num{
  font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "tnum" 1;
  letter-spacing: 0;
}

/* ---------- Layout ---------- */
.container{ max-width: 1120px; margin: 0 auto; padding: 0 1.25rem; }
.page{ padding-top: 1.75rem; padding-bottom: 3rem; }
.stack{ display: flex; flex-direction: column; gap: 1rem; }
.row{ display: flex; align-items: center; gap: .5rem; }
.between{ display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.muted{ color: hsl(var(--muted-foreground)); }
.small{ font-size: .8125rem; }
.mt-1{ margin-top: .5rem; } .mt-2{ margin-top: 1rem; } .mt-3{ margin-top: 1.5rem; }
.mb-2{ margin-bottom: 1rem; } .mb-3{ margin-bottom: 1.5rem; } .mb-4{ margin-bottom: 2rem; }
.text-right{ text-align: right; }
.nowrap{ white-space: nowrap; }
.fw-600{ font-weight: 600; }
.text-danger{ color: hsl(var(--destructive)); }
.text-success{ color: hsl(142 71% 35%); }

.grid{ display: grid; gap: 1rem; }
.stats{ display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-2{ display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-2-1{ display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
@media (max-width: 820px){
  .stats, .grid-2, .grid-2-1{ grid-template-columns: 1fr; }
}
@media (max-width: 640px){
  .container{ padding: 0 1.15rem; }
  .page{ padding-top: 1.1rem; padding-bottom: 2.5rem; }
  .card-body{ padding: 1rem; }
  .card-head{ padding: .9rem 1rem; }
  .stat{ padding: 1rem; }
  h1{ font-size: 1.3rem; }
  .stat-value{ font-size: 1.45rem; }

  /* Taşmayı önle: satırları dikey yığına çevir */
  .form-row{ flex-direction: column; align-items: stretch; }
  .form-row .select, .form-row .btn, .form-row .grow{ max-width: none; width: 100%; }

  .filter-bar{ flex-direction: column; align-items: stretch; }
  .filter-bar .seg{ width: 100%; }
  .filter-bar .seg-item{ flex: 1; text-align: center; }
  .filter-bar form{ width: 100%; }
  .filter-bar .date-input{ flex: 1; min-width: 0; }
}

/* ---------- Navbar ---------- */
.nav{
  background: hsl(var(--background));
  border-bottom: 1px solid hsl(var(--border));
  position: sticky; top: 0; z-index: 20;
}
.nav .container{ display: flex; align-items: center; height: 56px; gap: 1rem; }
.nav-brand{ display: flex; align-items: center; gap: .5rem; font-weight: 600; font-size: 1rem; flex: 0 0 auto; }
.nav-brand .brand-badge{
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 7px;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
}
.nav-toggle{
  display: none; margin-left: auto; width: 38px; height: 38px;
  align-items: center; justify-content: center;
  background: transparent; border: 1px solid hsl(var(--border));
  border-radius: var(--radius); color: inherit; cursor: pointer;
}
.nav-menu{ display: flex; align-items: center; flex: 1; gap: 1rem; }
.nav-links{ display: flex; align-items: center; gap: .25rem; }
.nav-link{
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .45rem .7rem; border-radius: var(--radius);
  color: hsl(var(--muted-foreground)); font-weight: 500;
}
.nav-link:hover{ background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.nav-link.active{ background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.nav-right{ margin-left: auto; display: flex; align-items: center; gap: .5rem; }

@media (max-width: 768px){
  .nav-toggle{ display: inline-flex; }
  .nav-menu{
    display: none; position: absolute; top: 56px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: .15rem;
    padding: .75rem 1.25rem 1rem;
    background: hsl(var(--background));
    border-bottom: 1px solid hsl(var(--border));
    box-shadow: 0 10px 24px rgb(0 0 0 / .07);
  }
  .nav.open .nav-menu{ display: flex; }
  .nav-links{ flex-direction: column; align-items: stretch; gap: .15rem; }
  .nav-link{ padding: .6rem .7rem; }
  .nav-right{
    margin-left: 0; flex-direction: column; align-items: stretch; gap: .5rem;
    margin-top: .5rem; padding-top: .75rem; border-top: 1px solid hsl(var(--border));
  }
  .nav-right .nav-link{ justify-content: flex-start; }
  .nav-right form, .nav-right .btn{ width: 100%; }
}

/* ---------- Card ---------- */
.card{
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.04);
}
.card-head{ padding: 1.1rem 1.25rem; border-bottom: 1px solid hsl(var(--border)); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card-title{ font-size: 1rem; font-weight: 600; }
.card-desc{ color: hsl(var(--muted-foreground)); font-size: .8125rem; margin-top: .15rem; }
.card-body{ padding: 1.25rem; }
/* Grid/ızgara içindeki kartlar boşluğu gap'ten alır (çift boşluk olmasın) */
.grid > .card, .grid-2 > .card, .grid-2-1 > .card, .stats > .card{ margin-bottom: 0; }

/* ---------- Stat card ---------- */
.stat{ padding: 1.25rem; }
.stat .between{ align-items: flex-start; }
.stat-label{ color: hsl(var(--muted-foreground)); font-size: .8125rem; font-weight: 500; }
.stat-value{ font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; margin-top: .35rem; }
.stat-ic{ display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: hsl(var(--muted)); color: hsl(var(--foreground)); }

/* ---------- Buttons ---------- */
.btn{
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  height: 2.25rem; padding: 0 1rem;
  border-radius: var(--radius); border: 1px solid transparent;
  font-size: .875rem; font-weight: 500; cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap; background: transparent; color: inherit;
}
.btn-sm{ height: 1.9rem; padding: 0 .7rem; font-size: .8125rem; }
.btn svg{ width: 1rem; height: 1rem; }
.btn-primary{ background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-primary:hover{ background: hsl(240 5.9% 20%); }
.btn-outline{ border-color: hsl(var(--border)); background: hsl(var(--background)); color: hsl(var(--foreground)); }
.btn-outline:hover{ background: hsl(var(--muted)); }
.btn-ghost{ color: hsl(var(--foreground)); }
.btn-ghost:hover{ background: hsl(var(--muted)); }
.btn-destructive{ border-color: hsl(var(--border)); background: hsl(var(--background)); color: hsl(var(--destructive)); }
.btn-destructive:hover{ background: hsl(0 72% 97%); border-color: hsl(0 72% 85%); }
.btn-icon{ width: 2.25rem; padding: 0; }
.btn-icon.btn-sm{ width: 1.9rem; }
.btn.disabled{ opacity: .45; pointer-events: none; }

/* ---------- Forms ---------- */
.field{ display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.label{ font-size: .8125rem; font-weight: 500; }
.input, .select, .textarea{
  width: 100%; height: 2.25rem; padding: 0 .75rem;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  font-size: .875rem; color: hsl(var(--foreground)); font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.textarea{ height: auto; padding: .55rem .75rem; min-height: 4.5rem; resize: vertical; }
.input:focus, .select:focus, .textarea:focus{
  outline: none; border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / .25);
}
.input::placeholder{ color: hsl(var(--muted-foreground)); }
.select{ appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .6rem center; padding-right: 2rem; }
.form-text{ font-size: .78rem; color: hsl(var(--muted-foreground)); }

.input-search{ position: relative; }
.input-search .icon{ position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: hsl(var(--muted-foreground)); }
.input-search .input{ padding-left: 2.1rem; }

.form-row{ display: flex; gap: .6rem; align-items: end; flex-wrap: wrap; }
.form-row .grow{ flex: 1 1 auto; }

/* Otomatik tamamlama (müşteri arama) */
.autocomplete{ position: relative; }
.ac-list{
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: var(--radius); box-shadow: 0 10px 24px rgb(0 0 0 / .09);
  max-height: 240px; overflow-y: auto;
}
.ac-item{ padding: .55rem .75rem; cursor: pointer; font-size: .875rem; }
.ac-item:hover, .ac-item.active{ background: hsl(var(--muted)); }
.ac-empty{ padding: .55rem .75rem; color: hsl(var(--muted-foreground)); font-size: .8125rem; }

/* ---------- Table ---------- */
/* grid + minmax(0,1fr): tablonun min-genişliği ebeveyni zorlamaz, kendi içinde kayar */
.table-wrap{ display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table{ width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th{
  text-align: left; font-weight: 500; color: hsl(var(--muted-foreground));
  padding: .6rem .75rem; border-bottom: 1px solid hsl(var(--border));
  font-size: .78rem; text-transform: none;
}
.table td{ padding: .7rem .75rem; border-bottom: 1px solid hsl(var(--border)); vertical-align: middle; }
.table th.text-right{ text-align: right; } /* başlık hizasını rakamlarla eşitle */
.table tbody tr:last-child td{ border-bottom: 0; }
.table tbody tr:hover td{ background: hsl(var(--muted) / .5); }
.table .empty{ text-align: center; color: hsl(var(--muted-foreground)); padding: 2rem; }
.table tbody tr.clickable{ cursor: pointer; }

/* Oran çubuğu (gider dağılımı) */
.bar{ background: hsl(var(--muted)); border-radius: 999px; height: 8px; overflow: hidden; min-width: 60px; }
.bar-fill{ height: 100%; background: hsl(var(--primary)); border-radius: 999px; }

/* Sürükle-bırak sıralama listesi */
.sortable-item{
  display: flex; align-items: center; gap: .5rem;
  padding: .55rem .25rem; border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--card));
}
.sortable-item:last-child{ border-bottom: 0; }
.sortable-item.dragging{ opacity: .4; }
.sortable-item .grow{ flex: 1 1 auto; min-width: 0; }
.drag-handle{ cursor: grab; color: hsl(var(--muted-foreground)); display: inline-flex; flex: 0 0 auto; }
.drag-handle:active{ cursor: grabbing; }

/* İş özeti değerleri (daha ölçülü boyut) */
.sum-value{ font-size: 1.3rem; font-weight: 600; margin-top: .2rem; letter-spacing: -0.01em; }
.sum-value.net{ font-size: 1.55rem; }

/* ---------- Segmented control (tarih ön ayarları) ---------- */
.seg{ display: inline-flex; border: 1px solid hsl(var(--border)); border-radius: var(--radius); overflow: hidden; background: hsl(var(--background)); }
.seg-item{ padding: .45rem .85rem; font-size: .8125rem; font-weight: 500; color: hsl(var(--muted-foreground)); border-right: 1px solid hsl(var(--border)); }
.seg-item:last-child{ border-right: 0; }
.seg-item:hover{ background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.seg-item.active{ background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.date-input{ width: auto; }

/* ---------- Badge ---------- */
.badge{
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .15rem .55rem; border-radius: 999px;
  font-size: .75rem; font-weight: 500; border: 1px solid transparent;
  white-space: nowrap;
}
.lbl-short{ display: none; }
@media (max-width: 640px){
  .lbl-full{ display: none; }
  .lbl-short{ display: inline; }
}
.badge-gray{ background: hsl(240 4.8% 95%); color: hsl(240 4% 40%); border-color: hsl(240 5% 88%); }
.badge-blue{ background: hsl(214 100% 96%); color: hsl(221 83% 45%); border-color: hsl(214 95% 88%); }
.badge-green{ background: hsl(142 76% 95%); color: hsl(142 71% 30%); border-color: hsl(142 60% 85%); }
.badge-red{ background: hsl(0 86% 97%); color: hsl(0 72% 45%); border-color: hsl(0 80% 90%); }

/* ---------- Alert ---------- */
.alert{ padding: .75rem 1rem; border-radius: var(--radius); font-size: .875rem; border: 1px solid transparent; margin-bottom: 1rem; }
.alert-error{ background: hsl(0 86% 97%); color: hsl(0 72% 42%); border-color: hsl(0 80% 90%); }
.alert-success{ background: hsl(142 76% 96%); color: hsl(142 71% 28%); border-color: hsl(142 60% 85%); }

/* ---------- Auth ---------- */
.auth{ min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-box{ width: 100%; max-width: 380px; }
.auth-logo{ display: flex; flex-direction: column; align-items: center; gap: .6rem; margin-bottom: 1.5rem; }
.auth-logo .brand-badge{ width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
