/* KABA — Görünüm. Renkler logodan alınmıştır: koyu antrasit + altın + gümüş. */
:root {
  --dark: #1c1b20;
  --dark-2: #2a2930;
  --gold: #c9a227;
  --gold-dark: #9c7c16;
  --gold-soft: #f6efd6;
  --bg: #f4f3f0;
  --card: #ffffff;
  --text: #1f1f24;
  --muted: #6b6a72;
  --line: #e3e1dc;
  --debt: #b3261e;
  --credit: #1b7a43;
  --ready: #1b7a43;
  --ready-soft: #e3f4ea;
  --warn: #a15c00;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--gold-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.num { text-align: right; white-space: nowrap; }
.ok { color: var(--credit); }
.late, .debt, .error-text { color: var(--debt); }
.credit { color: var(--credit); }
.warn { color: var(--warn); }

/* ---------- Üst bar ve menü */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--dark); color: #eee; padding: 0 1rem; height: 58px;
  border-bottom: 2px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: .5rem; color: #e9e9ec; font-weight: 800; letter-spacing: .12em; font-size: 1.15rem; }
.brand:hover { text-decoration: none; }
.brand img { height: 44px; width: 44px; display: block; border-radius: 8px; }
.brand small { color: var(--gold); font-weight: 500; letter-spacing: .2em; font-size: .7rem; margin-left: .2rem; }
.doc-toolbar .btn-primary { background: var(--gold); border-color: var(--gold); color: #111; }
.topbar-right { display: flex; align-items: center; gap: .6rem; }
.user-chip { font-size: .9rem; }
.user-chip small { color: var(--gold); margin-left: .2rem; }
.sync-badge { font-size: .75rem; padding: .2rem .55rem; border-radius: 99px; background: var(--dark-2); color: #cfcfd4; border: 1px solid #45444c; }
.sync-badge.offline { background: #5b3a00; color: #ffd27a; }
.sync-badge.error { background: #6b1d17; color: #ffb4ab; }
.auth-tabs { margin-bottom: 1rem; }
.auth-tabs .tab { font-size: .82rem; padding: .35rem .65rem; }
.topbar .btn-ghost { color: #ddd; border-color: #45444c; }

.layout { display: flex; min-height: calc(100vh - 58px); }
.sidenav { width: 200px; background: var(--card); border-right: 1px solid var(--line); padding: 1rem .6rem; flex-shrink: 0; }
.nav-item { display: flex; align-items: center; gap: .6rem; padding: .65rem .8rem; border-radius: 8px; color: var(--text); margin-bottom: 2px; }
.nav-item:hover { background: var(--bg); text-decoration: none; }
.nav-item.active { background: var(--dark); color: #fff; }
.nav-item.active .nav-icon { color: var(--gold); }
.nav-icon { width: 1.2rem; text-align: center; }
.bottomnav { display: none; }
.view { flex: 1; padding: 1.4rem; max-width: 1200px; width: 100%; }

/* ---------- Kartlar, düzen */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card-ready { border-color: var(--ready); background: linear-gradient(0deg, #fff, var(--ready-soft)); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.grid-2.tight { gap: .6rem; }
.span-2 { grid-column: span 2; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.empty { padding: 1.4rem; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty.small { padding: .8rem; }
.empty.error { color: var(--debt); }
.notice { background: var(--gold-soft); border: 1px solid #e6d59b; padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .92rem; }

.stats { margin-bottom: 1rem; }
.stat { display: flex; flex-direction: column; gap: .3rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; color: var(--text); box-shadow: var(--shadow); }
a.stat:hover { border-color: var(--gold); text-decoration: none; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat b { font-size: 1.35rem; }
.stats .stat b { font-size: 1.05rem; }
.stat-ready { border-color: var(--ready); }
.stat-ready b { color: var(--ready); }
.big-money { font-size: 1.5rem; font-weight: 700; line-height: 1.35; }

/* ---------- Butonlar */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--gold); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-primary { background: var(--dark); color: #fff; border-color: var(--dark); }
.btn-primary:hover { background: #000; border-color: var(--gold); }
.btn-ready { background: var(--ready); color: #fff; border-color: var(--ready); }
.btn-ghost { background: transparent; }
.btn-danger-ghost { color: var(--debt); }
.btn-sm { padding: .3rem .65rem; font-size: .85rem; }
.btn-block { width: 100%; }

/* ---------- Formlar */
.form { display: flex; flex-direction: column; gap: .8rem; }
.form.grid-2, .form .grid-4, .form .grid-2 { display: grid; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; color: #3b3a42; font-weight: 500; }
input, select, textarea {
  font: inherit; padding: .55rem .65rem; border: 1px solid #cfcdc7; border-radius: 8px; background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: -1px; border-color: var(--gold); }
input:disabled, select:disabled, textarea:disabled { background: #f2f1ee; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.inline-form { flex-direction: row; flex-wrap: wrap; align-items: center; margin-top: .6rem; }
.inline-form > * { width: auto; flex: 1 1 140px; }
.inline-form .btn { flex: 0 0 auto; }
.search { margin-bottom: .9rem; }
details.sub { margin-top: .8rem; border-top: 1px solid var(--line); padding-top: .8rem; }
details.sub summary { cursor: pointer; font-weight: 600; color: var(--gold-dark); margin-bottom: .8rem; }

/* ---------- Tablolar */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; padding: .55rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: .6rem; border-bottom: 1px solid #efeee9; vertical-align: top; }
.table th.num { text-align: right; }
.table td.mono { white-space: nowrap; }
.table select { min-width: 150px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #faf8f2; }
tr.row-ready td { background: var(--ready-soft); }
tr.row-ready td:first-child { box-shadow: inset 4px 0 0 var(--ready); }

/* ---------- Rozetler */
.status { display: inline-block; font-size: .78rem; font-weight: 600; padding: .18rem .55rem; border-radius: 99px; background: #ecebe7; color: #444; white-space: nowrap; }
.status-taslak { background: #ecebe7; color: #555; }
.status-alindi { background: #e4ecfb; color: #1f4fa8; }
.status-hazirlandi { background: var(--ready); color: #fff; }
.status-teslim { background: #e3f4ea; color: #1b7a43; }
.status-iptal { background: #fbe4e2; color: var(--debt); text-decoration: line-through; }
.chip { display: inline-block; font-size: .82rem; padding: .15rem .5rem; border-radius: 6px; background: #efeee9; white-space: nowrap; margin: 1px 0; }
.chip-debt { background: #fbe9e7; color: var(--debt); font-weight: 600; }
.chip-credit { background: #e3f4ea; color: var(--credit); font-weight: 600; }
.balance-big .chip { font-size: 1.1rem; padding: .35rem .7rem; }

dl.info { display: grid; grid-template-columns: 140px 1fr; gap: .45rem .8rem; margin: 0; }
dl.info dt { color: var(--muted); font-size: .88rem; }
dl.info dd { margin: 0; }

/* ---------- Sekmeler */
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .9rem; }
.tab { padding: .4rem .8rem; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--text); font-size: .9rem; }
.tab small { color: var(--muted); }
.tab.active { background: var(--dark); color: #fff; border-color: var(--dark); }
.tab.active small { color: var(--gold); }

/* ---------- Model kartları */
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.model-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); box-shadow: var(--shadow); }
.model-card:hover { border-color: var(--gold); text-decoration: none; }
.model-photo { aspect-ratio: 4/3; background: #f0efeb; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .8rem; overflow: hidden; }
.model-photo img { width: 100%; height: 100%; object-fit: cover; }
.model-photo.big { width: 260px; max-width: 100%; border-radius: var(--radius); }
.model-photo.sm { width: 64px; height: 48px; aspect-ratio: auto; border-radius: 6px; flex-shrink: 0; }
.model-body { padding: .7rem .8rem; display: flex; flex-direction: column; gap: .15rem; }
.model-body .price { margin-top: .3rem; font-weight: 700; }
.photo-field { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }

/* ---------- Sipariş satırları */
.line-card { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; background: #fcfbf8; display: flex; flex-direction: column; gap: .7rem; }
.line-head { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.line-head .grow { flex: 1 1 220px; }
.line-head label:not(.grow) { flex: 0 1 150px; }
.sizes { display: flex; flex-wrap: wrap; gap: .4rem; }
.size-cell { width: 64px; text-align: center; gap: .15rem; }
.size-cell span { font-weight: 700; font-size: .85rem; }
.size-cell input { text-align: center; padding: .45rem .2rem; }
.size-cell.extra { width: 90px; }
.size-cell.extra span { font-weight: 500; color: var(--muted); }
.line-foot { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.line-foot label { width: 170px; }
.order-total { font-size: 1.1rem; text-align: right; padding: .6rem 0; border-top: 2px solid var(--dark); }
#lines { display: flex; flex-direction: column; gap: .8rem; }
.status-bar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; padding: .7rem 1rem; }
.ship-card { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; margin-bottom: .6rem; }
.ship-card.taslak { border-style: dashed; background: #fffdf6; }
.ship-head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.ship-card ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.doc-list { list-style: none; padding: 0; margin: 0; }
.doc-list li { padding: .45rem 0; border-bottom: 1px solid #efeee9; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.history { margin: 0; padding-left: 1.1rem; max-height: 320px; overflow: auto; }
.history li { margin-bottom: .25rem; }

/* ---------- Sürüm 2 eklemeleri */
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 1.2rem 0 .6rem; }
.stat b.big { font-size: 1.15rem; line-height: 1.35; }
.notice-link { display: block; color: var(--text); }
.notice-link:hover { border-color: var(--gold); text-decoration: none; }
.cat-list { list-style: none; padding: 0; margin: 0 0 .6rem; }
.cat-list li { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .45rem 0; border-bottom: 1px solid #efeee9; }
.cat-list li a { font-weight: 600; flex: 1 1 140px; color: var(--text); }
.cat-list li a.active { color: var(--gold-dark); }
.row-cancelled td { color: #999; text-decoration: line-through; }
.row-cancelled td .late { text-decoration: none; }
.total-row td { border-top: 2px solid var(--dark); }
.line-sum { font-weight: 700; min-width: 110px; text-align: right; padding-bottom: .6rem; }
.doc-photo { max-width: 100%; max-height: 480px; border-radius: 8px; border: 1px solid var(--line); margin-top: .6rem; }
.check { flex-direction: row; align-items: center; gap: .4rem; }
.check input { width: auto; }
.st-cur { font-size: 10.5pt; margin: 5mm 0 1.5mm; }
.st-table td { vertical-align: top; }
.st-open td { background: #f7f6f2; font-style: italic; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.st-lines { margin: 1mm 0 0; padding-left: 4mm; font-size: 8.5pt; color: #333; }
.page-break { break-after: page; height: 0; }
.sidenav { overflow-y: auto; }

/* ---------- Giriş */
body.auth-page { background: radial-gradient(circle at 50% 0%, #34323a, var(--dark) 70%); min-height: 100vh; }
.auth-card { max-width: 400px; margin: 6vh auto; background: #fff; border-radius: 14px; padding: 0 1.6rem 1.6rem; box-shadow: 0 10px 40px rgba(0,0,0,.35); overflow: hidden; }
.auth-logo { display: block; width: calc(100% + 3.2rem); margin: 0 -1.6rem 1.2rem; background: var(--dark); }
.auth-card h1 { margin-bottom: .6rem; }

/* ---------- Bildirimler */
#toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 100; display: flex; flex-direction: column; gap: .5rem; max-width: 380px; }
.toast { background: var(--dark); color: #fff; padding: .75rem 1rem; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); border-left: 4px solid var(--gold); }
.toast-error { border-left-color: #ff6b5e; }

/* ---------- Belge (A4) */
body.doc-page { background: #d9d8d4; }
.doc-toolbar { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; padding: .8rem 1rem; background: var(--dark); color: #ddd; position: sticky; top: 0; z-index: 5; }
.doc-toolbar .muted { color: #bbb; }
.a4 { width: 210mm; min-height: 297mm; margin: 1.2rem auto; background: #fff; padding: 0 14mm 12mm; box-shadow: 0 4px 24px rgba(0,0,0,.2); font-size: 10.5pt; color: #111; display: flex; flex-direction: column; }
.doc-head { display: flex; align-items: center; justify-content: space-between; background: var(--dark); color: #e9e9ec; margin: 0 -14mm; padding: 4mm 14mm; border-bottom: 3px solid var(--gold); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc-logo { height: 30mm; }
.doc-biz { text-align: right; font-size: 9.5pt; line-height: 1.5; }
.doc-biz b { color: var(--gold); font-size: 12pt; }
.doc-title-row { display: flex; justify-content: space-between; align-items: flex-start; margin: 7mm 0 4mm; }
.doc-title-row h1 { font-size: 18pt; letter-spacing: .08em; }
.doc-meta th { text-align: left; color: #666; font-weight: 500; padding: 1px 10px 1px 0; }
.doc-customer { border: 1px solid #ddd; border-left: 4px solid var(--gold); padding: 3mm 4mm; margin-bottom: 5mm; line-height: 1.5; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc-customer > span:first-child { display: block; color: #777; font-size: 8.5pt; text-transform: uppercase; letter-spacing: .05em; }
.doc-table { width: 100%; border-collapse: collapse; }
.doc-table th { background: #f1efe9; text-align: left; font-size: 8.5pt; text-transform: uppercase; padding: 2.2mm 2mm; border-bottom: 1.5px solid #222; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc-table th.num { text-align: right; }
.doc-table td { padding: 2.2mm 2mm; border-bottom: 1px solid #e5e5e5; vertical-align: middle; }
.doc-table td.thumb { width: 18mm; }
.doc-table td.thumb img { width: 16mm; height: 12mm; object-fit: cover; border-radius: 2px; display: block; }
.doc-summary { margin: 6mm 0 0 auto; width: 95mm; border: 1.5px solid #222; }
.doc-summary h2 { font-size: 9pt; text-transform: uppercase; letter-spacing: .05em; margin: 0; padding: 2mm 3mm; background: var(--dark); color: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.sum-row { display: flex; justify-content: space-between; padding: 2mm 3mm; border-bottom: 1px solid #e5e5e5; }
.sum-total { background: var(--gold-soft); font-size: 12pt; border-bottom: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc-notes { margin-top: 5mm; }
.doc-bank { margin-top: 5mm; }
.doc-bank h3 { font-size: 9.5pt; margin: 0 0 1mm; }
.doc-bank pre { font-family: inherit; white-space: pre-wrap; margin: 0; font-size: 9.5pt; }
.doc-foot { margin-top: auto; padding-top: 6mm; border-top: 1px solid #ccc; font-size: 8.5pt; color: #444; }
.doc-foot p { margin: .4mm 0; }

@media print {
  @page { size: A4; margin: 0; }
  body.doc-page { background: #fff; }
  .no-print { display: none !important; }
  .a4 { margin: 0; box-shadow: none; width: 210mm; min-height: 296mm; }
}

/* ---------- Mobil */
@media (max-width: 860px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  :root { font-size: 15px; }
  .sidenav { display: none; }
  .view { padding: 1rem .8rem 5.5rem; }
  .bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--dark); border-top: 2px solid var(--gold); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .bottomnav { overflow-x: auto; scrollbar-width: none; }
  .bottomnav .nav-item { flex: 0 0 76px; flex-direction: column; gap: .1rem; font-size: .7rem; color: #cfcfd4; padding: .45rem 0; border-radius: 0; margin: 0; }
  .bottomnav .nav-item.active { background: transparent; color: var(--gold); }
  .bottomnav .nav-icon { font-size: 1.15rem; }
  .user-chip, .sync-badge { display: none; }
  .brand img { height: 38px; width: 38px; }
  .grid-2, .form.grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  dl.info { grid-template-columns: 1fr; gap: .1rem; }
  dl.info dd { margin-bottom: .4rem; }
  .a4 { width: 100%; min-height: auto; padding: 0 4mm 6mm; margin: 0; }
  .doc-head { margin: 0 -4mm; padding: 3mm 4mm; }
  .doc-logo { height: 18mm; }
  .doc-summary { width: 100%; }
  .table { font-size: .86rem; }
}
/* Yazdırırken telefonda da tam A4 düzeni kullanılsın */
@media print {
  .a4 { width: 210mm; padding: 0 14mm 12mm; }
  .doc-head { margin: 0 -14mm; padding: 4mm 14mm; }
  .doc-logo { height: 30mm; }
  .doc-summary { width: 95mm; }
}
