/* PROSES ERP — responsive arayüz (telefon / tablet / masaüstü) */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #1d4ed8;
  --primary-2: #1e40af;
  --primary-soft: #e8efff;
  --danger: #dc2626;
  --success: #15803d;
  --warn: #b45309;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
  --topbar: 56px;
  --sidebar: 248px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --surface: #111827; --surface-2: #0f172a; --border: #1f2a3c;
    --text: #e5e7eb; --muted: #94a3b8; --primary: #3b82f6; --primary-2: #60a5fa; --primary-soft: #172554;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.45; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .15rem; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.ico { width: 18px; height: 18px; flex: none; }
.logo { width: 30px; height: 30px; }

/* ---------- topbar & shell */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar); display: flex; align-items: center; gap: .6rem;
  padding: 0 .9rem; padding-top: env(safe-area-inset-top); background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; color: var(--text); letter-spacing: .04em; }
.brand:hover { text-decoration: none; }
.topbar-spacer { flex: 1; }
.top-search input { width: 300px; max-width: 34vw; }
.user-chip { display: flex; flex-direction: column; line-height: 1.1; text-align: right; }
.user-chip small { color: var(--muted); font-size: .75rem; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.nav-toggle { display: none; }
.shell { display: flex; min-height: calc(100vh - var(--topbar)); }
.sidebar { position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); width: var(--sidebar); flex: none; overflow-y: auto;
  padding: .75rem .6rem 2rem; background: var(--surface); border-right: 1px solid var(--border); }
.nav-group { margin-bottom: .6rem; }
.nav-title { font-size: .7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding: .4rem .6rem; }
.nav-link { display: flex; align-items: center; gap: .6rem; padding: .5rem .65rem; border-radius: 9px; color: var(--text); font-size: .93rem; }
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-backdrop { display: none; }
.content { flex: 1; min-width: 0; padding: 1.25rem 1.5rem 4rem; max-width: 1500px; }

/* ---------- page parts */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-header p { margin: .1rem 0 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.back { display: inline-block; margin-bottom: .5rem; font-size: .9rem; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.stat .k { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat .v { font-size: 1.5rem; font-weight: 750; margin-top: .2rem; }
.stat a { color: inherit; }
.stat.pos .v { color: var(--success); } .stat.neg .v { color: var(--danger); }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .6rem 1.25rem; }
.kv { display: flex; flex-direction: column; min-width: 0; }
.kv .k { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kv .v { overflow-wrap: anywhere; }
.empty { padding: 1.5rem; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }
.alert { padding: .7rem .9rem; border-radius: 10px; margin-bottom: .9rem; border: 1px solid; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-info { background: var(--primary-soft); border-color: transparent; color: var(--primary-2); }
.alert-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ---------- badges */
.badge { display: inline-flex; align-items: center; padding: .12rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 650; white-space: nowrap;
  background: #eef2f7; color: #334155; }
.badge.blue { background: #dbeafe; color: #1e40af; } .badge.green { background: #dcfce7; color: #166534; }
.badge.red { background: #fee2e2; color: #991b1b; } .badge.amber { background: #fef3c7; color: #92400e; }
.badge.teal { background: #ccfbf1; color: #115e59; } .badge.indigo { background: #e0e7ff; color: #3730a3; }
.badge.gray { background: #eef2f7; color: #475569; }
@media (prefers-color-scheme: dark) { .badge { filter: saturate(.9) brightness(.95); } }

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 38px; padding: .45rem .9rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger { background: var(--surface); border-color: #fecaca; color: var(--danger); }
.btn.danger:hover { background: #fef2f2; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 30px; padding: .2rem .6rem; font-size: .85rem; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.inline-form { display: inline; }

/* ---------- forms */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 600; color: var(--muted); }
input, select, textarea { font: inherit; font-size: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: .5rem .65rem; min-height: 40px; width: 100%; font-weight: 400; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .85rem 1rem; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters label { min-width: 160px; flex: 1 1 160px; }
.filters .btn { flex: none; }

/* ---------- tables */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { padding: .55rem .7rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.tbl th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); font-weight: 700; white-space: nowrap; position: sticky; top: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border); }
.tbl tr.row-head td { background: var(--surface-2); font-weight: 700; }
.tbl tr.row-pct td { font-style: italic; }
.tbl tr.row-warn td { background: #fff7ed; }
.tbl tr.row-ok td { background: #f0fdf4; }
@media (prefers-color-scheme: dark) { .tbl tr.row-warn td { background: #2a1a0b; } .tbl tr.row-ok td { background: #0b2a17; } }
.tbl input, .tbl select { min-height: 36px; padding: .3rem .45rem; font-size: 15px; }
.tbl .w-num { width: 110px; } .tbl .w-sm { width: 90px; } .tbl .w-xs { width: 60px; }
.edit-tbl td { padding: .3rem .35rem; }
.pager { display: flex; gap: .75rem; align-items: center; justify-content: center; margin-top: 1rem; }

/* ---------- stepper */
.stepper { display: flex; list-style: none; padding: 0; margin: 0 0 1rem; gap: .25rem; overflow-x: auto; scrollbar-width: thin; }
.stepper li { flex: 1 0 auto; display: flex; flex-direction: column; align-items: center; gap: .25rem; min-width: 74px; position: relative; font-size: .76rem; color: var(--muted); }
.stepper li::before { content: ""; position: absolute; top: 13px; left: -50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.stepper li:first-child::before { display: none; }
.stepper .dot { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 2px solid var(--border); font-weight: 700; font-size: .8rem; }
.stepper li.done .dot { background: var(--success); border-color: var(--success); color: #fff; }
.stepper li.done::before, .stepper li.current::before { background: var(--success); }
.stepper li.current .dot { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--primary-soft); }
.stepper li.current { color: var(--text); font-weight: 700; }

/* ---------- tabs / doc list */
.doc-list { display: flex; flex-direction: column; gap: .4rem; }
.doc-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); flex-wrap: wrap; }
.doc-row .t { font-weight: 600; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.timeline li { padding: .35rem 0; border-bottom: 1px dashed var(--border); }
.timeline li:last-child { border: 0; }

/* ---------- login / error */
body.bare { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 1rem;
  background: radial-gradient(1200px 600px at 10% -10%, #dbe6ff 0, transparent 60%), var(--bg); }
.login-wrap { width: 100%; max-width: 380px; }
.login-card { display: flex; flex-direction: column; gap: .9rem; padding: 1.6rem; }
.login-brand { display: flex; align-items: center; gap: .7rem; margin-bottom: .4rem; }
.login-brand .logo { width: 44px; height: 44px; }
.login-brand strong { display: block; font-size: 1.3rem; letter-spacing: .06em; }
.login-brand small { color: var(--muted); }
body.error-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 1rem; }
.error-card { max-width: 480px; }

/* ---------- toast */
.toast { position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(150%); z-index: 60;
  background: #0f172a; color: #fff; padding: .7rem 1.1rem; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.25); transition: transform .25s ease; max-width: 92vw; }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

/* ---------- print documents (teklif, hakediş, irsaliye) */
.doc { background: #fff; color: #000; max-width: 1000px; margin: 0 auto; padding: 1.5rem; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.doc table { width: 100%; border-collapse: collapse; }
.doc th, .doc td { border: 1px solid #94a3b8; padding: 4px 6px; vertical-align: top; }
.doc th { background: #e2e8f0; font-size: 11px; }
.doc td.num { text-align: right; white-space: nowrap; }
.doc .doc-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; gap: 1rem; }
.doc h1 { font-size: 18px; } .doc h2 { font-size: 15px; margin: 1.2rem 0 .5rem; }
.doc .row-head td { font-weight: 700; background: #f1f5f9; }
.doc .sign { display: flex; justify-content: space-between; margin-top: 2.5rem; gap: 2rem; }
.doc .sign div { flex: 1; text-align: center; border-top: 1px solid #000; padding-top: .4rem; }
.print-bar { display: flex; gap: .5rem; justify-content: flex-end; margin-bottom: 1rem; max-width: 1000px; margin-left: auto; margin-right: auto; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .topbar, .sidebar, .print-bar, .no-print, .toast, .nav-backdrop { display: none !important; }
  .content { padding: 0; max-width: none; }
  .doc { border: 0; padding: 0; max-width: none; }
  .doc tr { page-break-inside: avoid; }
}

/* ---------- tablet */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top-search input { width: 200px; }
}
/* ---------- telefon / dar tablet: menü çekmece olur */
@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .sidebar { position: fixed; left: 0; top: var(--topbar); z-index: 40; transform: translateX(-105%); transition: transform .22s ease; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: var(--topbar) 0 0 0; background: rgba(15,23,42,.35); z-index: 35; }
  .content { padding: 1rem .85rem 5rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .user-chip { display: none; }
  .top-search { flex: 1; }
  .top-search input { width: 100%; max-width: none; }
  .brand span { display: none; }
  .form-grid .span-2 { grid-column: auto; }
}
@media (max-width: 560px) {
  h1 { font-size: 1.25rem; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .stat .v { font-size: 1.15rem; }
  .page-header .actions { width: 100%; }
  .page-header .actions .btn { flex: 1 1 auto; }
  /* kart görünümlü tablolar */
  .tbl.cards thead { display: none; }
  .tbl.cards, .tbl.cards tbody, .tbl.cards tr, .tbl.cards td { display: block; width: 100%; }
  .tbl.cards tr { border-bottom: 1px solid var(--border); padding: .5rem .2rem; }
  .tbl.cards td { border: 0; padding: .2rem .6rem; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  .tbl.cards td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; font-weight: 600; text-align: left; flex: none; }
  .tbl.cards td.num { justify-content: space-between; }
  .tbl.cards tfoot { display: block; }
  .tbl.cards tfoot tr { display: block; }
  .tbl.cards tfoot td:empty { display: none; }
  .form-actions .btn { flex: 1; }
}
.edit-tbl input[list=items-dl] { min-width: 210px; }
