:root {
  --bg: #f5f3ef; --card: #fff; --text: #2a2622; --muted: #8a8178; --line: #e6e0d8;
  --accent: #8b5e34; --accent-2: #f1e6da; --ok: #2f7d4f; --warn: #b7791f; --bad: #b83b3b;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
header { display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { padding: 7px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); user-select: none; }
nav a:hover { background: var(--accent-2); color: var(--text); }
nav a.active { background: var(--accent); color: #fff; }
main { padding: 20px; max-width: 1300px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0 0 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
h1 .spacer { flex: 1; }
h2 { font-size: 15px; margin: 0 0 10px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 18px; }
.cols { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 12px; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
.card table { background: none; }
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; cursor: default; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #faf8f5; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
.muted { color: var(--muted); }
.strike { text-decoration: line-through; color: var(--muted); }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
input, select, textarea { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); border-color: var(--accent); }
textarea { width: 100%; min-height: 60px; }
button { font: inherit; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--text); white-space: nowrap; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { color: var(--bad); }
button.sm { padding: 3px 8px; font-size: 12px; }
.actions { display: flex; gap: 4px; justify-content: flex-end; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.b-beklemede { background: #fdf0d8; color: var(--warn); }
.b-teslim_edildi { background: #def2e5; color: var(--ok); }
.b-iptal { background: #f7dddd; color: var(--bad); }
.b-satis { background: #e5eefc; color: #2d5fa8; }
.b-siparis { background: #fdf0d8; color: var(--warn); }
.b-manuel { background: #eee; color: #555; }
.b-iade { background: #def2e5; color: var(--ok); }
.stok-0 { color: var(--bad); font-weight: 700; }
.stok-low { color: var(--warn); font-weight: 700; }
dialog { border: none; border-radius: 14px; padding: 0; width: min(720px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(30,25,20,.4); }
dialog form { padding: 18px 20px; }
dialog h2 { font-size: 17px; margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 12px; }
.form-grid label, .field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form-grid .wide { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.items td { padding: 5px 6px; }
.items input, .items select { width: 100%; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #2a2622; color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 100; }
#toast.show { opacity: 1; }
#toast.err { background: var(--bad); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 8px; }
.bars div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars div:hover { background: #a8743f; }
.hbar { height: 8px; background: var(--accent-2); border-radius: 4px; overflow: hidden; min-width: 80px; }
.hbar span { display: block; height: 100%; background: var(--accent); }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
@media (max-width: 640px) { main { padding: 12px; } .cols { grid-template-columns: 1fr; } }
.orders td:nth-child(2), .orders td:nth-child(6) { white-space: nowrap; }
.orders td:nth-child(4) { min-width: 160px; }
.orders td:nth-child(5) { min-width: 240px; }
.orders .actions { flex-wrap: wrap; min-width: 150px; }
