:root {
  --green: #72a565;
  --green-dark: #4e7d43;
  --green-darker: #3a5f32;
  --green-soft: #e6f0df;
  --green-bg: #f3f8ee;
  --cream: #f8fbe6;
  --paper: #ffffff;
  --ink: #1f2a1c;
  --muted: #66705f;
  --line: #dde3d3;
  --warn: #a86a12;
  --warn-soft: #fdf3dd;
  --bad: #c0392b;
  --bad-soft: #fbe6e3;
  --blue: #2f6f9f;
  --blue-soft: #e3eef7;
  --radius: 12px;
  --bottom: 0px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; color: var(--ink); background: var(--cream); line-height: 1.4;
}
a { color: var(--green-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 18px 0 10px; }
.sub { color: var(--muted); margin: -6px 0 14px; }
.muted { color: var(--muted); }
.small, small { font-size: 13px; }
.diff { color: var(--bad); font-weight: 600; }
.strike { text-decoration: line-through; opacity: .6; }

/* ---------- üst bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; background: var(--paper); height: 56px;
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 16px;
}
.topbar .brand img { height: 38px; display: block; }
.topbar .who { margin-left: auto; text-align: right; font-size: 13px; color: var(--muted); line-height: 1.25; }
.topbar .who b { color: var(--ink); display: block; font-size: 14px; }
.menu-btn { display: none; background: none; border: 0; font-size: 26px; padding: 4px 6px; cursor: pointer; }

.layout { display: flex; min-height: calc(100vh - 56px); }
nav.side { width: 236px; flex: none; background: var(--paper); border-right: 1px solid var(--line); padding: 10px 8px 30px; }
.side-who { display: none; padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
nav.side a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 12px; border-radius: 10px;
  text-decoration: none; color: var(--ink); font-weight: 500; margin-bottom: 2px;
}
nav.side a i { font-style: normal; width: 26px; display: inline-block; }
nav.side a:hover { background: var(--green-soft); }
nav.side a.active { background: var(--green-dark); color: #fff; }
nav.side .badge { background: var(--bad); color: #fff; border-radius: 99px; font-size: 12px; padding: 1px 8px; font-weight: 700; }
nav.side a.active .badge { background: #fff; color: var(--green-dark); }
nav.side hr { border: 0; border-top: 1px solid var(--line); margin: 8px 4px; }
.shade { display: none; }
main { flex: 1; padding: 20px 24px 120px; max-width: 1100px; min-width: 0; }
nav.bottom { display: none; }

/* ---------- kartlar, formlar ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.card.tight { padding: 0; overflow: hidden; }
.form-top { display: grid; gap: 12px; }
.grid-f { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; align-items: end; }
.row-2 { display: flex; gap: 8px; align-items: center; }
.row-2 > input { flex: 1; }
label.f, div.f { display: flex; flex-direction: column; gap: 5px; font-size: 14px; color: var(--muted); min-width: 0; }
label.f > span, div.f > span { font-weight: 600; color: var(--ink); }
.f.end { justify-content: flex-end; }
.fields { display: grid; gap: 14px; }
input[type=text], input[type=password], input[type=date], input[type=search], input[type=number], select, textarea {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; min-height: 46px; width: 100%; font-size: 16px;
}
textarea { min-height: 60px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: -1px; border-color: var(--green); }
input:disabled { background: #f3f4f0; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; color: var(--ink); min-height: 36px; }
.check input { width: 22px; height: 22px; accent-color: var(--green-dark); flex: none; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line);
  background: #fff; border-radius: 10px; padding: 10px 16px; cursor: pointer; font-weight: 600; min-height: 46px;
  text-decoration: none; color: var(--ink); font-size: 15px; text-align: center;
}
.btn:hover { border-color: var(--green); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }
.btn.primary:hover { background: var(--green-darker); }
.btn.danger { color: var(--bad); border-color: #efc9c4; }
.btn.small { padding: 6px 12px; min-height: 38px; font-size: 14px; }
.btn.big { padding: 14px 20px; font-size: 17px; min-height: 54px; }
.btn.block { display: flex; width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row.two > .btn { flex: 1; }
.linkbtn { background: none; border: 0; color: var(--green-dark); font-weight: 600; cursor: pointer; padding: 6px 0; font-size: 14px; }

.chip { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 700; white-space: nowrap; margin-right: 4px; }
.chip.yeni { background: var(--blue-soft); color: var(--blue); }
.chip.hazir { background: var(--green-soft); color: var(--green-dark); }
.chip.sevk { background: var(--warn-soft); color: var(--warn); }
.chip.teslim { background: #eceee9; color: #4a5245; }
.chip.iptal, .chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.ok { background: var(--green-soft); color: var(--green-dark); }

.note { background: var(--warn-soft); border-left: 3px solid var(--warn); padding: 7px 10px; border-radius: 8px; font-size: 14px; margin-top: 6px; }
.note b { color: var(--warn); }
.note.prod { background: var(--blue-soft); border-color: var(--blue); }
.note.prod b { color: var(--blue); }
.badge-w, .badge-r { display: inline-block; font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 8px; margin-top: 6px; }
.badge-w { background: #fff1cc; color: #8a5a00; }
.badge-r { background: var(--bad-soft); color: var(--bad); }
.info-bar { display: block; background: var(--blue-soft); color: var(--blue); padding: 12px 14px; border-radius: var(--radius); margin-bottom: 14px; text-decoration: none; font-weight: 500; }

/* gün seçici, segment, sekmeler */
.daypick { display: flex; gap: 6px; flex-wrap: wrap; }
.daypick button, .daypick .cal {
  border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 9px 16px; cursor: pointer; font-weight: 600; min-height: 42px;
  display: inline-flex; align-items: center; gap: 4px; position: relative; font-size: 15px;
}
.daypick button.on, .daypick .cal.on { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }
.daypick .cal input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; padding: 0; border: 0; }
.seg { display: flex; background: #eef2e8; border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px 8px; border-radius: 8px; font-weight: 600; cursor: pointer; color: var(--muted); font-size: 14px; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 8px 15px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.tabs button.on { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }

/* tablolar */
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.t tbody tr:last-child td { border-bottom: 0; }
table.t th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafcf5; font-weight: 700; }
table.t td.n, table.t th.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #fafcf5; }
.table-wrap { overflow-x: auto; }
.cat-row { background: var(--green-bg); font-weight: 700; }
.pen { color: var(--warn); margin-left: 4px; }

/* ana sayfa */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 8px; }
.tile { display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; color: var(--ink); }
.tile:hover { border-color: var(--green); }
.tile i { font-style: normal; font-size: 30px; width: 52px; height: 52px; border-radius: 14px; background: var(--green-soft); display: flex; align-items: center; justify-content: center; flex: none; }
.tile b { display: block; font-size: 17px; }
.tile span { color: var(--muted); font-size: 14px; }
.tile.alert { border-color: #f0c36a; background: #fffbef; }
.tile.alert i { background: #fff1cc; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .v { font-size: 28px; font-weight: 800; color: var(--green-dark); }
.stat .l { color: var(--muted); font-size: 14px; }

/* sipariş formu */
.cat { border-bottom: 1px solid var(--line); }
.cat:last-child { border-bottom: 0; }
.cat-h { display: flex; width: 100%; justify-content: space-between; align-items: center; padding: 14px 16px; cursor: pointer; background: #fafcf5; font-weight: 700; border: 0; text-align: left; font-size: 16px; }
.cat-h .cnt { font-size: 13px; background: var(--green-dark); color: #fff; border-radius: 99px; padding: 2px 10px; }
.cat-h .arrow { color: var(--muted); margin-left: 10px; }
.prow { padding: 10px 16px 8px; border-top: 1px solid #eef1e8; }
.prow .top { display: flex; align-items: center; gap: 12px; }
.prow .name { flex: 1; font-weight: 600; min-width: 0; }
.prow .name small { display: block; color: var(--muted); font-weight: 400; }
.prow .under { display: flex; }
.prow.has { background: var(--green-bg); }
.prow textarea { margin-top: 6px; min-height: 44px; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; flex: none; }
.stepper button { width: 46px; height: 46px; border: 0; background: #f0f4ea; font-size: 22px; cursor: pointer; font-weight: 600; }
.stepper button:active { background: var(--green-soft); }
.stepper input { width: 64px; border: 0; text-align: center; min-height: 46px; border-radius: 0; padding: 0 4px; font-weight: 700; font-size: 18px; }
.stepper input:focus { outline: none; background: #fffef3; }
.stepper.sm button { width: 38px; height: 40px; font-size: 19px; }
.stepper.sm input { width: 56px; min-height: 40px; font-size: 16px; }
.unit { color: var(--muted); font-size: 14px; min-width: 32px; }
.note-btn { border: 0; background: none; padding: 6px 0; cursor: pointer; font-size: 14px; color: var(--muted); font-weight: 500; }
.note-btn.on { color: var(--warn); font-weight: 700; }
.sticky-bar {
  position: fixed; bottom: var(--bottom); left: 236px; right: 0; background: var(--paper); border-top: 1px solid var(--line);
  padding: 10px 24px; display: flex; align-items: center; gap: 12px; z-index: 25; box-shadow: 0 -4px 16px rgba(0,0,0,.05);
}
.sticky-bar .info { flex: 1; }
.sum-list { display: grid; gap: 2px; }
.sum-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #eef1e8; }
.sum-row:last-child { border-bottom: 0; }

/* kalem kartları */
.group-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; background: #fafcf5; border-bottom: 1px solid var(--line); }
.group-h .big, b.big { font-size: 17px; }
.group-h .tot b { font-size: 20px; color: var(--green-dark); }
.group-f { padding: 12px 14px; display: grid; gap: 10px; border-top: 1px solid var(--line); background: #fcfdf9; }
.lcard, .pcard { padding: 12px 14px; border-bottom: 1px solid #eef1e8; }
.lcard:last-child, .pcard:last-of-type { border-bottom: 0; }
.lc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.lc-name { font-weight: 700; font-size: 16px; min-width: 0; }
.lc-name small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.lc-qty { font-size: 22px; font-weight: 800; white-space: nowrap; text-align: right; }
.lc-qty small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.lc-status { margin-top: 6px; font-size: 14px; }
.lc-act { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.lc-act .linkbtn { margin-left: auto; }
.cancelled .lc-name, .cancelled .lc-qty { text-decoration: line-through; opacity: .55; }
.pcard.st-hazir { background: var(--green-bg); }
.pcard.st-iptal { background: #fdf3f2; }
.pcard.st-iptal .lc-name { text-decoration: line-through; opacity: .6; }
.pcard.st-sevk, .pcard.st-teslim { opacity: .75; }
.pc-act { margin-top: 10px; display: grid; gap: 8px; }
.pc-edit { display: grid; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.pc-foot { text-align: right; margin-top: -4px; }
.done-line { font-weight: 700; color: var(--green-dark); }
.done-line.short { color: var(--bad); }
.done-line small { font-weight: 400; color: var(--muted); }
.big-empty { font-size: 18px; padding: 40px 10px; }
.cat-title { margin: 18px 4px 8px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.sumcard { padding: 12px 14px; }
.sumcard .lc-top { margin-bottom: 6px; }

/* sevkiyat ve teslim satırları */
.srow { padding: 12px 14px; border-bottom: 1px solid #eef1e8; display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; }
.srow > .note, .srow > div:not(.srow-l):not(.srow-r) { grid-column: 1 / -1; }
.srow.off { opacity: .45; }
.srow-l { display: flex; gap: 12px; align-items: center; cursor: pointer; min-width: 0; }
.srow-l input { width: 24px; height: 24px; accent-color: var(--green-dark); flex: none; }
.srow-l small { display: block; }
.srow-r { display: flex; align-items: center; gap: 6px; }

/* geçmiş */
.tl { list-style: none; margin: 8px 0 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.tl li { position: relative; padding: 0 0 14px 12px; font-size: 14px; }
.tl li::before { content: ''; position: absolute; left: -26px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); border: 2px solid #fff; }
.tl li.b::before { background: var(--blue); }
.tl li.g::before { background: var(--green); }
.tl li.o::before { background: var(--warn); }
.tl li.w::before { background: #e0a100; }
.tl li.r::before { background: var(--bad); }
.tl-t { font-size: 12.5px; color: var(--muted); }
.hcard .flow { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 8px; font-size: 14px; }
.hcard.cancelled .lc-name { text-decoration: line-through; opacity: .6; }
ul.roles { margin: 6px 0 0; padding-left: 18px; }
ul.roles li { margin-bottom: 4px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 30, 15, .45); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; overflow-y: auto; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 520px; display: flex; flex-direction: column; max-height: calc(100vh - 80px); }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 6px; }
.modal-h h2 { margin: 0; font-size: 19px; }
.modal-h .x { border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.modal-b { padding: 8px 18px 14px; overflow-y: auto; }
.modal-actions { display: flex; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-actions .btn.primary { flex: 1; }

#toast { position: fixed; bottom: calc(var(--bottom) + 90px); left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: 92vw; }
#toast div { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.2); text-align: center; }
#toast div.err { background: var(--bad); }

/* giriş */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login .box { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 28px 22px; width: 100%; max-width: 380px; }
.login img { width: 100%; max-width: 240px; display: block; margin: 0 auto 8px; }
.login p { text-align: center; color: var(--muted); margin: 0 0 20px; }
.login form { display: grid; gap: 12px; }

.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.loading { color: var(--muted); padding: 30px 10px; text-align: center; }
.only-m { display: none; }

/* sevk fişi */
.fis { background: #fff; max-width: 800px; margin: 0 auto; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); }
.fis-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; border-bottom: 2px solid var(--green); padding-bottom: 12px; margin-bottom: 14px; }
.fis-head img { height: 60px; }
.fis-head .r { text-align: right; }
.fis-head .r h1 { font-size: 20px; margin: 0; }
.fis .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; margin-bottom: 14px; font-size: 14px; }
.fis .meta .wide { grid-column: 1 / -1; }
.sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 50px; }
.sign div { border-top: 1px solid var(--ink); padding-top: 6px; text-align: center; font-size: 13px; }

@media print {
  .topbar, nav.side, nav.bottom, .no-print, .sticky-bar, #toast, .only-m { display: none !important; }
  .only-d { display: block !important; }
  body, main { background: #fff; padding: 0; }
  .fis { border: 0; padding: 0; }
}

/* ---------- telefon ---------- */
@media (max-width: 860px) {
  :root { --bottom: 64px; }
  body { font-size: 16px; }
  .menu-btn { display: block; }
  .topbar { padding: 0 10px 0 14px; }
  .topbar .brand img { height: 34px; }
  nav.side {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 70; width: 82vw; max-width: 320px; transform: translateX(105%);
    transition: transform .2s; box-shadow: -4px 0 24px rgba(0,0,0,.15); overflow-y: auto; border: 0;
  }
  .side-who { display: block; }
  body.menu-open nav.side { transform: none; }
  body.menu-open .shade { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 65; }
  main { padding: 14px 12px calc(var(--bottom) + 100px); }
  h1 { font-size: 21px; }
  nav.bottom {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: var(--bottom); z-index: 40; background: #fff;
    border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  nav.bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11.5px; font-weight: 600; position: relative; }
  nav.bottom a i { font-style: normal; font-size: 22px; line-height: 1; }
  nav.bottom a.active { color: var(--green-dark); }
  nav.bottom a.active i { transform: scale(1.1); }
  nav.bottom em { position: absolute; top: 4px; left: calc(50% + 6px); background: var(--bad); color: #fff; font-style: normal; font-size: 11px; border-radius: 99px; padding: 0 6px; min-width: 18px; text-align: center; }
  .sticky-bar { left: 0; padding: 10px 12px; }
  .sticky-bar .btn.big { padding: 12px 18px; }
  .only-m { display: block; }
  .only-d { display: none !important; }
  .tiles { grid-template-columns: 1fr; }
  .grid-f { grid-template-columns: 1fr 1fr; }
  .row-2 { flex-wrap: wrap; }
  .row-2 > input { flex-basis: 100%; }
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal { max-width: none; border-radius: 18px 18px 0 0; max-height: 92vh; }
  .modal-actions { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .modal-actions .btn { flex: 1; }
  .fis { padding: 14px; }
  .fis .meta { grid-template-columns: 1fr; }
  .fis-head img { height: 44px; }

  /* tablolar telefonda kart olur */
  table.resp thead { display: none; }
  table.resp, table.resp tbody, table.resp tr, table.resp td { display: block; width: 100%; }
  table.resp tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  table.resp tbody tr:last-child { border-bottom: 0; }
  table.resp td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.resp td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; flex: none; }
  table.resp td[data-label=""]::before { content: none; }
  table.resp td.main { font-weight: 700; font-size: 16px; text-align: left; }
  table.resp td.main::before { content: none; }
  table.resp td.n { text-align: right; }
  .with-cb table.resp td:first-child { justify-content: flex-start; }
}
@media (max-width: 380px) {
  .stepper button { width: 40px; }
  .stepper input { width: 54px; }
}
