:root {
  --bg: #f4f5f7; --card: #fff; --text: #1d2330; --muted: #5b6270; --line: #e6e8ec; --thead: #f6f7f9; --row: #eef0f3;
  --accent: #f27a1a; --pos: #13854e; --neg: #c62f2f; --warn: #a86400; --bar: #1d2330; --indigo: #3d4bb0;
  --t-orange: #fff1e6; --t-orange-tx: #8a3d06; --t-indigo: #eef2ff; --t-indigo-tx: #2f3c8f; --t-gray: #f1f3f6; --t-gray-tx: #3a4250;
  --t-red: #fdecec; --t-red-tx: #8e1f1f; --t-green: #e8f6ee; --t-green-tx: #0f5b37; --t-amber: #fdf4e3; --t-amber-tx: #7a4a05;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #12151b; --card: #1a1e26; --text: #e7e9ee; --muted: #9aa2b3; --line: #2a303b; --thead: #20252f; --row: #232833;
          --pos: #3ccf86; --neg: #ff6b6b; --warn: #f0b04a; --bar: #0b0d11; --indigo: #9aa6ff;
          --t-orange: #3a2414; --t-orange-tx: #ffb27a; --t-indigo: #23284a; --t-indigo-tx: #b9c1ff; --t-gray: #232833; --t-gray-tx: #c9cfda;
          --t-red: #3a1d1f; --t-red-tx: #ff9b9b; --t-green: #15301f; --t-green-tx: #7fe0ab; --t-amber: #352a12; --t-amber-tx: #f5c36b; }
}
:root[data-theme="dark"] { --bg: #12151b; --card: #1a1e26; --text: #e7e9ee; --muted: #9aa2b3; --line: #2a303b; --thead: #20252f; --row: #232833;
          --pos: #3ccf86; --neg: #ff6b6b; --warn: #f0b04a; --bar: #0b0d11; --indigo: #9aa6ff;
          --t-orange: #3a2414; --t-orange-tx: #ffb27a; --t-indigo: #23284a; --t-indigo-tx: #b9c1ff; --t-gray: #232833; --t-gray-tx: #c9cfda;
          --t-red: #3a1d1f; --t-red-tx: #ff9b9b; --t-green: #15301f; --t-green-tx: #7fe0ab; --t-amber: #352a12; --t-amber-tx: #f5c36b; }
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
header { position: sticky; top: 0; z-index: 10; }
header .bar { display: flex; align-items: center; gap: 20px; padding: 0 16px; height: 52px; background: var(--bar); color: #fff; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; color: #fff; text-decoration: none; white-space: nowrap; }
.brand .logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; font-size: 14px; }
#groups { display: flex; gap: 4px; height: 100%; }
#groups button { background: none; border: 0; color: #b8bfcc; padding: 0 12px; height: 100%; cursor: pointer; font: inherit; font-weight: 500; border-bottom: 3px solid transparent; border-top: 3px solid transparent; }
#groups button:hover { color: #fff; }
#groups button.active { color: #fff; border-bottom-color: var(--accent); }
.spacer { flex: 1; }
header .bar .ghost { color: #d5dae3; border-color: #3a4150; }
.iconbtn { background: none; border: 1px solid #3a4150; color: #d5dae3; width: 32px; height: 32px; border-radius: 6px; cursor: pointer; font-size: 15px; }
header .subbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 6px 16px; background: var(--card); border-bottom: 1px solid var(--line); min-height: 46px; }
#tabs { display: flex; gap: 2px; flex-wrap: wrap; }
#tabs button { background: none; color: var(--muted); border: 0; padding: 7px 12px; border-radius: 6px; cursor: pointer; font: inherit; }
#tabs button:hover { color: var(--text); background: var(--bg); }
#tabs button.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); font-weight: 500; }
.filters { display: flex; gap: 6px; align-items: center; margin-left: auto; flex-wrap: wrap; }
@media (max-width: 700px) { header .bar { gap: 8px; overflow-x: auto; } .brand { font-size: 0; gap: 0; } #groups button { padding: 0 8px; } }
input, select, button { font: inherit; }
input, select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text); }
button.primary, .login-card button { background: var(--accent); color: #fff; border: 0; padding: 7px 14px; border-radius: 6px; cursor: pointer; }
button.ghost { background: none; border: 1px solid var(--line); color: var(--text); padding: 5px 10px; border-radius: 6px; cursor: pointer; }
main { padding: 16px; max-width: 2200px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 20px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .muted { color: var(--muted); } .warn { color: var(--warn); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-weight: 600; color: var(--muted); font-size: 12px; position: sticky; top: 0; background: var(--card); cursor: pointer; }
td.num, th.num { text-align: right; }
td input.cost { width: 90px; text-align: right; }
.notice { padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--warn) 15%, transparent); margin-bottom: 16px; }
.error { color: var(--neg); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
h2 { font-size: 15px; margin: 0 0 12px; }
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 10px; }
.login-card h1 { margin: 0; font-size: 20px; }
canvas { max-height: 320px; }
.prod { display: flex; gap: 10px; align-items: center; min-width: 260px; max-width: 440px; }
.thumb { width: 40px; height: 40px; flex: none; border-radius: 6px; object-fit: cover; background: var(--line); display: inline-block; }
.prod-title { font-weight: 500; line-height: 1.3; }
.prod-title a { color: inherit; text-decoration: none; }
.prod-title a:hover { text-decoration: underline; }
.prod-meta { font-size: 12px; margin-top: 2px; }
.kpi-btn { text-align: left; font: inherit; color: inherit; cursor: pointer; }
.kpi-btn:hover { border-color: var(--muted); }
tr.inv:hover td { background: var(--bg); }
td:has(> .prod) { white-space: normal; min-width: 300px; }
.prod { min-width: 0; }
.prod-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.prod-meta { white-space: normal; }
.est { border-bottom: 1px dotted var(--muted); cursor: help; }
td .sub { font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 1px; }
.dbar { display: flex; height: 6px; width: 110px; margin: 4px 0 0 auto; border-radius: 3px; overflow: hidden; background: var(--line); }
.dbar i { display: block; height: 100%; }
.dbar.big { width: 100%; height: 18px; margin: 0 0 10px; border-radius: 5px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.kpi-hl { border-color: #f76b15; }
.kpi-hl .value { color: #f76b15; }
#prodTable th:first-child, #prodTable td:first-child { position: sticky; left: 0; z-index: 1; background: var(--card); box-shadow: 1px 0 0 var(--line); }
#prodTable td:first-child { max-width: 340px; }
/* Ürün tablosu: kutu içinde iki yönlü kaydırma; başlık satırı ve ürün sütunu sabit */
#prodTable { max-height: calc(100vh - 140px); overflow: auto; scrollbar-gutter: stable; }
#prodTable thead th { position: sticky; top: 0; z-index: 2; }
#prodTable thead th:first-child { z-index: 3; }
#prodTable::-webkit-scrollbar { height: 12px; width: 10px; }
#prodTable::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 6px; }
#prodTable::-webkit-scrollbar-track { background: var(--line); }
/* ---------- Siparişler ---------- */
.accent { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: none; color: var(--text); padding: 5px 12px; border-radius: 999px; cursor: pointer; font: inherit; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--text); text-decoration: none; }
.badge.ok, .st-Delivered, .st-Shipped { background: color-mix(in srgb, var(--pos) 18%, transparent); color: var(--pos); }
.badge.bad, .st-Cancelled, .st-UnSupplied, .st-UnDelivered, .st-Returned { background: color-mix(in srgb, var(--neg) 18%, transparent); color: var(--neg); }
.st-Created, .st-Picking, .st-Invoiced { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
button.outline { background: none; border: 1px solid var(--accent); color: var(--accent); padding: 6px 10px; border-radius: 6px; cursor: pointer; font: inherit; }
button.outline:disabled { opacity: .45; cursor: default; }
button.danger { background: var(--neg); color: #fff; border: 0; padding: 7px 14px; border-radius: 6px; cursor: pointer; }
button.sm { font-size: 12px; padding: 4px 8px; }
button.icon { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: 13px; }
.otable td { vertical-align: top; padding: 10px; }
.otable tr.orow:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.oline { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: start; }
.oline + .oline { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.oimg { position: relative; width: 56px; height: 56px; border-radius: 6px; background: var(--line); }
.oimg img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.oimg .qty { position: absolute; top: -6px; right: -6px; background: #3b82f6; color: #fff; border-radius: 50%; width: 20px; height: 20px; font-size: 11px; display: grid; place-items: center; }
.acts { display: flex; flex-direction: column; gap: 6px; min-width: 190px; }
details.menu { position: relative; }
details.menu summary { list-style: none; cursor: pointer; text-align: center; padding: 5px; border-radius: 6px; font-weight: 600; }
details.menu summary::after { content: " ▾"; }
details.menu[open] summary { background: var(--line); }
details.menu > div { position: absolute; right: 0; z-index: 5; min-width: 240px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); padding: 6px; display: flex; flex-direction: column; }
details.menu > div button { text-align: left; background: none; border: 0; color: var(--text); padding: 9px 12px; border-radius: 6px; cursor: pointer; font: inherit; }
details.menu > div button:hover { background: var(--line); }
details.menu > div button.neg { color: var(--neg); }
dialog.dlg { border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); width: min(560px, calc(100vw - 32px)); padding: 20px; }
dialog.dlg.wide { width: min(980px, calc(100vw - 32px)); }
dialog.dlg::backdrop { background: rgba(0,0,0,.55); }
dialog.dlg h2 { margin-top: 0; }
dialog.dlg h3 { font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
dialog.dlg label { display: block; margin-top: 8px; font-size: 13px; }
dialog.dlg .chips { margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 24px; }
table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini td, table.mini th { padding: 5px 6px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--card); padding: 10px 18px; border-radius: 8px; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.3); }

/* ---------- Operasyon paneli ---------- */
.ops-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.ops-card { text-align: left; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: var(--card); color: var(--text); cursor: pointer; font: inherit; }
.ops-card:hover { border-color: var(--accent); }
.ops-card .label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.ops-card .value { font-size: 26px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.ops-card .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.ops-card.hot { border-color: color-mix(in srgb, var(--neg) 60%, var(--line)); }
.ops-card.hot .value { color: var(--neg); }
.ops-list td { vertical-align: middle; }

/* ---------- Kompakt operasyon görünümü ---------- */
body { font-size: 13px; }
main { padding: 14px 16px; }
.card { border-radius: 8px; padding: 14px; margin-bottom: 14px; }
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
.kpis { gap: 8px; margin-bottom: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi { border-radius: 8px; padding: 10px 12px; }
.kpi .label { font-size: 11px; }
.kpi .value { font-size: 18px; }
table { font-size: 13px; }
th { background: var(--thead) !important; color: var(--muted); font-weight: 600; font-size: 12px; padding: 7px 8px; border-bottom: 1px solid var(--line); }
td { padding: 7px 8px; border-bottom: 1px solid var(--row); }
.table-wrap { border: 1px solid var(--line); border-radius: 8px; }
.card > .table-wrap:only-child, .card[style*="padding:0"] .table-wrap { border: 0; }
input, select { padding: 5px 8px; }
button.primary { padding: 6px 12px; }
button.primary:hover { filter: brightness(1.06); }
.chip { padding: 4px 11px; font-size: 12px; }
/* Durum kartları (operasyon paneli) */
.ops-cards { gap: 8px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 14px; }
.ops-card { border: 0; border-radius: 8px; padding: 10px 12px; }
.ops-card .label { color: inherit; opacity: .85; font-size: 12px; }
.ops-card .value { font-size: 22px; margin-top: 2px; }
.ops-card:hover { border: 0; outline: 2px solid color-mix(in srgb, currentColor 30%, transparent); }
.ops-card .dot { display: none; }
.tint-orange { background: var(--t-orange); color: var(--t-orange-tx); }
.tint-indigo { background: var(--t-indigo); color: var(--t-indigo-tx); }
.tint-gray { background: var(--t-gray); color: var(--t-gray-tx); }
.tint-red { background: var(--t-red); color: var(--t-red-tx); }
.tint-green { background: var(--t-green); color: var(--t-green-tx); }
.tint-amber { background: var(--t-amber); color: var(--t-amber-tx); }
.ops-card.hot { border: 0; } .ops-card.hot .value { color: inherit; }
/* Durum rozetleri aynı paletten */
.badge { border-radius: 6px; font-weight: 500; }
.st-Created { background: var(--t-orange); color: var(--t-orange-tx); }
.st-Picking { background: var(--t-indigo); color: var(--t-indigo-tx); }
.st-Invoiced, .st-Shipped { background: var(--t-gray); color: var(--t-gray-tx); }
.st-Delivered, .badge.ok { background: var(--t-green); color: var(--t-green-tx); }
.st-Cancelled, .st-UnSupplied, .st-UnDelivered, .st-Returned, .badge.bad { background: var(--t-red); color: var(--t-red-tx); }
/* Satır içi işlem bağlantıları */
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; font: inherit; font-weight: 600; }
button.link:hover { text-decoration: underline; }
/* ---------- Pazaryeri seçici ---------- */
.mpswitch { display: flex; gap: 2px; background: rgba(255,255,255,.06); border: 1px solid #343b49; border-radius: 9px; padding: 3px; }
.mpswitch button { display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; color: #c3c9d4; padding: 5px 11px; border-radius: 6px; cursor: pointer; font: inherit; font-weight: 500; white-space: nowrap; }
.mpswitch button:hover { color: #fff; background: rgba(255,255,255,.07); }
.mpswitch button.on { background: #fff; color: #1d2330; }
.mpswitch button.off { color: #8b93a3; }
.mpswitch button.off.on { color: #1d2330; }
.mpswitch .soon { font-size: 10px; font-weight: 500; padding: 1px 6px; border-radius: 999px; background: rgba(255,255,255,.1); color: #aab2c0; }
.mpswitch button.on .soon { background: #eef0f3; color: #5b6270; }
.mpdot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.mpdot.all { background: conic-gradient(#f27a1a 0 25%, #ff6000 0 50%, #7b3fe4 0 75%, #ff9900 0); }
.mpdot.big { width: 14px; height: 14px; }
.card.empty { text-align: center; padding: 48px 16px; }
.card.empty h2 { margin: 10px 0 6px; }
@media (max-width: 1100px) { .mpswitch .soon { display: none; } }
@media (max-width: 900px) { header .bar { height: auto; flex-wrap: wrap; padding: 8px 16px; } #groups { height: 40px; } .mpswitch { order: 5; width: 100%; overflow-x: auto; } }
/* ---------- Aylık kırılım ---------- */
:root { --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; }
:root[data-theme="dark"] { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; } }
.mlegend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.mlegend span { display: inline-flex; align-items: center; gap: 6px; }
.mlegend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.mrow { display: grid; grid-template-columns: 150px 1fr 170px; gap: 14px; align-items: center; padding: 8px 0; border-top: 1px solid var(--row); }
.mrow:first-child { border-top: 0; }
.mlabel b, .mval b { display: block; font-size: 14px; }
.mlabel span, .mval span { font-size: 12px; color: var(--muted); }
.mval { text-align: right; }
.mbar { display: flex; gap: 2px; height: 30px; }
.mseg { min-width: 3px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.mseg:first-child { border-radius: 4px 0 0 4px; } .mseg:last-child { border-radius: 0 4px 4px 0; }
.mseg span { color: #fff; font-size: 12px; font-weight: 600; text-shadow: 0 0 2px rgba(0,0,0,.35); white-space: nowrap; }
.mseg:hover { filter: brightness(1.08); }
@media (max-width: 700px) { .mrow { grid-template-columns: 1fr; gap: 4px; } .mval { text-align: left; } }
