:root {
  --bg: #f4f6f9; --panel: #fff; --text: #1d2433; --muted: #6b7385; --line: #e3e7ee;
  --primary: #1f6feb; --primary-d: #1658c4; --ok: #1a7f37; --warn: #b26a00; --bad: #c62828;
  --side: #17202e; --side-t: #c9d1de; --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-t); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 17px; padding: 18px 18px 14px; color: #fff; letter-spacing: .3px; }
.brand.big { color: var(--text); font-size: 22px; padding: 0 0 12px; text-align: center; }
.sidebar nav { display: flex; flex-direction: column; padding: 4px 8px; gap: 2px; flex: 1; }
.sidebar nav a { color: var(--side-t); padding: 9px 12px; border-radius: 6px; }
.sidebar nav a:hover { background: #222d3f; color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.side-foot { padding: 12px 18px; border-top: 1px solid #263248; display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.side-foot .btn.link { color: var(--side-t); }

main { padding: 22px 26px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.stat .v { font-size: 22px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .grid2 { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f6f9ff; }
tr.sub td { color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; }
.empty { color: var(--muted); padding: 18px; text-align: center; }

.btn { border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 13px; border-radius: 6px; cursor: pointer; font: inherit; white-space: nowrap; }
.btn:hover { border-color: #c5cdd9; background: #f8f9fb; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.link { border: 0; background: none; color: var(--primary); padding: 0; }
.btn:disabled { opacity: .55; cursor: default; }

input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #ccd3de; border-radius: 6px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b6d0fb; border-color: var(--primary); }
textarea { resize: vertical; min-height: 70px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
.help { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filters > * { width: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-beklemede, .b-bekliyor, .b-qr_bekleniyor, .b-baslatiliyor, .b-yazdiriliyor { background: #fff4e0; color: var(--warn); }
.b-onaylandi, .b-tamam, .b-hazir, .b-dogrulandi { background: #e6f4ea; color: var(--ok); }
.b-iptal, .b-hata, .b-baglanti_koptu, .b-kapali, .b-devre_disi { background: #fdecea; color: var(--bad); }
.pos { color: var(--bad); } .neg { color: var(--ok); }

/* sipariş editörü */
.piece { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; background: #fcfdff; }
.piece-main { display: grid; grid-template-columns: 34px 2.2fr 1fr 1fr 0.8fr 1fr 32px; gap: 8px; align-items: end; }
.piece-no { font-weight: 700; color: var(--muted); padding-bottom: 8px; }
.piece-total { text-align: right; padding-bottom: 8px; font-variant-numeric: tabular-nums; font-weight: 600; }
.services { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding-left: 42px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #eef3fb; border: 1px solid #d6e2f5; border-radius: 99px; padding: 2px 4px 2px 10px; font-size: 13px; }
.chip input { width: 48px; padding: 2px 4px; font-size: 12px; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 15px; }
.services select { width: auto; padding: 3px 6px; font-size: 13px; }
.totals { margin-left: auto; width: 320px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 18px; font-weight: 700; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.alert { padding: 10px 12px; border-radius: 6px; margin-bottom: 10px; font-size: 13px; }
.alert.err { background: #fdecea; color: var(--bad); }
.alert.warn { background: #fff4e0; color: var(--warn); }
.alert.info { background: #eaf2ff; color: #1b4f9c; }
pre.raw { white-space: pre-wrap; background: #f6f8fa; border: 1px solid var(--line); border-radius: 6px; padding: 10px; font-size: 13px; margin: 0; }

.modal { position: fixed; inset: 0; background: rgba(15, 22, 35, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal-box { background: #fff; border-radius: 10px; padding: 20px; width: 100%; max-width: 640px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #17202e; color: #fff; padding: 10px 14px; border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.2); max-width: 380px; }
.toast.err { background: var(--bad); }

.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #e9eef6, #f7f9fc); }
.login-box { background: #fff; padding: 28px; border-radius: 12px; width: 340px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 10px 40px rgba(20,40,80,.12); }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }
.qr { width: 280px; height: 280px; border: 1px solid var(--line); border-radius: 8px; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .piece-main { grid-template-columns: 1fr 1fr; }
  .piece-no { display: none; }
  .services { padding-left: 0; }
}
