/* Defne Doğal — stock & order panel demo */

:root {
  --side: #0f172a;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --brand: #4f46e5;
  --brand-soft: #eef2ff;
  --good: #15803d;
  --good-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); line-height: 1.5; overflow-x: hidden; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.demo-strip {
  display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: space-between; align-items: center;
  padding: 8px 16px; font-size: 0.78rem; background: #020617; color: #cbd5e1;
}
.demo-strip strong { color: #a5b4fc; }
.demo-strip a { color: #fff; font-weight: 600; text-decoration: none; }
.demo-strip a:hover { text-decoration: underline; }

/* ---- Shell ---------------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 34px); background: linear-gradient(to right, var(--side) 240px, transparent 240px); }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px;
  padding: 22px 14px 56px; background: var(--side); color: #cbd5e1;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; padding: 0 8px; }
.brand strong { display: block; color: #fff; font-size: 1rem; }
.brand small { color: #94a3b8; font-size: 0.8rem; }
.logo {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, #818cf8, #4f46e5); color: #fff; font-weight: 800;
}
.menu { display: grid; gap: 4px; }
.menu a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  text-decoration: none; font-weight: 600; font-size: 0.94rem; transition: background 0.15s, color 0.15s;
}
.menu a svg { width: 20px; height: 20px; flex: none; }
.menu a:hover { background: rgb(255 255 255 / 0.06); color: #fff; }
.menu a[aria-current="page"] { background: rgb(129 140 248 / 0.16); color: #fff; }
.menu a[aria-current="page"] svg { color: #a5b4fc; }
.pill-count {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; display: grid; place-items: center;
  background: #f59e0b; color: #1f1300; font-size: 0.74rem; font-weight: 800;
}
[data-new-orders] { background: #818cf8; color: #fff; }
.pill-count[hidden] { display: none; }
.reset { margin-top: auto; border: 1px solid rgb(255 255 255 / 0.12); background: none; color: #94a3b8; padding: 8px 12px; border-radius: 10px; font-size: 0.85rem; }
.reset:hover { color: #fff; }

main { padding: 28px clamp(16px, 3vw, 36px) 60px; min-width: 0; }
main:focus, main:focus-visible { outline: none; }

/* ---- Common ---------------------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 22px; }
.eyebrow { color: var(--muted); font-size: 0.86rem; font-weight: 500; }
.page-head h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 10px; background: var(--brand); color: #fff; font-weight: 600; font-size: 0.92rem;
  text-decoration: none; transition: filter 0.15s, transform 0.1s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.98); }
.btn.ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: #f8fafc; filter: none; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 0.84rem; }
.link { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 600; font-size: 0.88rem; text-decoration: none; }
.link:hover { text-decoration: underline; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card); font-size: 1.1rem; font-weight: 600; color: var(--ink-2);
}
.icon-btn:hover { background: var(--brand-soft); color: var(--brand); border-color: #c7d2fe; }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn svg { width: 16px; height: 16px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.panel-head h2 { font-size: 1rem; font-weight: 700; }
.panel-head .muted { font-size: 0.84rem; }
.empty { color: var(--muted); text-align: center; padding: 28px 0; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 0.74rem; font-weight: 700;
  background: var(--good-soft); color: var(--good); white-space: nowrap;
}
.chip i { font-style: normal; font-weight: 800; }
.chip.low { background: var(--warn-soft); color: var(--warn); }
.chip.out { background: var(--bad-soft); color: var(--bad); }
.bar { position: relative; display: block; height: 6px; border-radius: 999px; background: #e2e8f0; margin-top: 6px; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: #22c55e; }
.bar.low > span { background: #f59e0b; }
.bar.out > span { background: #ef4444; }
.bar em { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--ink-2); border-radius: 1px; }

/* ---- Overview ------------------------------------------------------------------------ */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.kpi { display: grid; gap: 4px; padding: 18px 20px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; }
.kpi h2 { font-size: 0.86rem; font-weight: 600; color: var(--muted); }
.kpi h2 small { font-weight: 500; }
.kpi .value { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 1rem; font-weight: 600; color: var(--muted); }
.kpi .sub { color: var(--muted); font-size: 0.82rem; }
.trend { font-size: 0.82rem; font-weight: 700; }
.trend small { font-weight: 500; color: var(--muted); }
.trend.up { color: var(--good); }
.trend.down { color: var(--bad); }
.kpi.alert { background: linear-gradient(135deg, #fff7ed, #fffbeb); border-color: #fde68a; transition: box-shadow 0.15s; }
.kpi.alert:hover { box-shadow: 0 6px 20px rgb(180 83 9 / 0.12); }
.kpi.alert .value { color: var(--warn); }
.kpi.alert.calm { background: var(--card); border-color: var(--line); }
.kpi.alert.calm .value { color: var(--good); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.grid-2 + .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: #e2e8f0; stroke-width: 1; }
.chart text { font-family: "Inter", sans-serif; font-size: 11px; fill: var(--muted); stroke: none; }
.chart text.y { text-anchor: end; }
.chart text.x { text-anchor: middle; }
.bar-g path { fill: #6366f1; stroke: none; transition: fill 0.15s; }
.bar-g.today path { fill: #4338ca; }
.bar-g .hit { fill: transparent; stroke: none; }
.bar-g.hover path, .bar-g:focus path { fill: #312e81; }
.bar-g:focus { outline: none; }
.chart .tip {
  position: absolute; top: -6px; transform: translate(-50%, -100%); pointer-events: none; display: grid; gap: 1px; text-align: center;
  padding: 8px 12px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 0.8rem; white-space: nowrap;
  box-shadow: 0 8px 20px rgb(15 23 42 / 0.25);
}
.chart .tip b { font-size: 0.98rem; }
.chart .tip span { color: #cbd5e1; }
.chart .tip[hidden] { display: none; }
.table-view { margin-top: 10px; font-size: 0.86rem; }
.table-view summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.table-view table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.table-view th, .table-view td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }

.low-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.low-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.low-list li:last-child { border-bottom: 0; }
.low-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.low-main strong { font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.low-main > span { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--muted); }

.top-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.top-list li { display: grid; grid-template-columns: 24px minmax(0, 1.3fr) minmax(0, 1fr) 32px; align-items: center; gap: 10px; font-size: 0.9rem; }
.rank { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--brand-soft); color: var(--brand); font-weight: 800; font-size: 0.78rem; }
.t-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-bar { height: 8px; border-radius: 4px; background: #eef2ff; overflow: hidden; }
.t-bar span { display: block; height: 100%; background: #6366f1; border-radius: 0 4px 4px 0; }
.top-list b { text-align: right; font-variant-numeric: tabular-nums; }

.mv-list { list-style: none; margin: 0; padding: 0; }
.mv-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.mv-list li:last-child { border-bottom: 0; }
.mv-name { flex: 1; min-width: 0; display: grid; }
.mv-name small { color: var(--muted); font-size: 0.78rem; }
.mv-badge { display: inline-block; min-width: 54px; text-align: center; padding: 2px 8px; border-radius: 6px; font-size: 0.74rem; font-weight: 700; background: #f1f5f9; color: var(--ink-2); }
.mv-badge.in { background: var(--good-soft); color: var(--good); }
.mv-badge.sale { background: var(--brand-soft); color: var(--brand); }
.mv-badge.loss { background: var(--bad-soft); color: var(--bad); }
.mv-badge.count { background: var(--warn-soft); color: var(--warn); }
.pos { color: var(--good); }
.neg { color: var(--ink-2); }
b.pos, b.neg, td.pos b, td.neg b { font-variant-numeric: tabular-nums; }

/* ---- Toolbar & tables ------------------------------------------------------------------ */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.search {
  display: flex; align-items: center; gap: 8px; flex: 1 1 240px; max-width: 360px; height: 42px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card);
}
.search svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; }
.toolbar select { height: 42px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: var(--card); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 8px; font-weight: 600; font-size: 0.86rem; color: var(--muted); }
.seg button b { font-weight: 700; margin-left: 2px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.seg button[aria-pressed="true"] b { color: #c7d2fe; }

.table-panel { padding: 0; overflow: hidden; }
table.ptable, table.mtable { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.ptable th, .mtable th {
  text-align: left; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700;
  padding: 12px 14px; background: #f8fafc; border-bottom: 1px solid var(--line);
}
.ptable td, .mtable td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ptable tbody tr:last-child td, .mtable tbody tr:last-child td { border-bottom: 0; }
.ptable tbody tr:hover, .mtable tbody tr:hover { background: #fafbff; }
.ptable tr.out td:first-child { box-shadow: inset 3px 0 0 #ef4444; }
.ptable tr.low td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
.ptable td small { display: block; color: var(--muted); font-size: 0.78rem; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.stock-cell { min-width: 150px; }
.stock-top { display: inline-flex; gap: 8px; align-items: center; justify-content: flex-end; }
.stock-cell .bar { margin-left: auto; width: 110px; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .icon-btn + .icon-btn { margin-left: 4px; }
.more { padding: 12px 14px; font-size: 0.84rem; }

/* ---- Orders --------------------------------------------------------------------------------- */
.orders { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.order { display: grid; gap: 10px; padding: 16px 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.order header, .order footer { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.order header > div { font-size: 0.92rem; }
.order ul { list-style: none; margin: 0; padding: 10px 0; display: grid; gap: 6px; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); font-size: 0.9rem; }
.order li { display: flex; justify-content: space-between; gap: 10px; }
.order li span:last-child { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.order footer .muted { font-size: 0.82rem; margin-right: auto; }
.ostatus { padding: 3px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 700; background: #f1f5f9; color: var(--ink-2); }
.ostatus.new { background: var(--brand-soft); color: var(--brand); }
.ostatus.packed { background: var(--warn-soft); color: var(--warn); }
.ostatus.shipped { background: #e0f2fe; color: #0369a1; }
.ostatus.delivered { background: var(--good-soft); color: var(--good); }

/* ---- Dialog ------------------------------------------------------------------------------------ */
dialog {
  width: min(480px, calc(100% - 24px)); padding: 0; border: 0; border-radius: 18px; color: var(--ink);
  box-shadow: 0 30px 80px rgb(15 23 42 / 0.35);
}
dialog[open] { animation: pop-in 0.2s ease-out; }
dialog::backdrop { background: rgb(15 23 42 / 0.45); backdrop-filter: blur(2px); }
.dform { display: grid; gap: 14px; padding: 20px 22px 22px; }
.dform header { display: flex; justify-content: space-between; align-items: center; }
.dform h2 { font-size: 1.15rem; }
.x { width: 34px; height: 34px; border: 0; border-radius: 50%; background: #f1f5f9; font-size: 1.3rem; line-height: 1; }
.dform label { display: grid; gap: 5px; font-size: 0.84rem; font-weight: 600; color: var(--ink-2); }
.dform label[hidden] { display: none; }
.dform input, .dform select {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; font-weight: 500; color: var(--ink);
}
.dform input:focus, .dform select:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgb(79 70 229 / 0.18); background: #fff; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wide-seg { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; }
.wide-seg legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.wide-seg label { display: block; position: relative; }
.wide-seg input { position: absolute; opacity: 0; inset: 0; height: 100%; cursor: pointer; }
.wide-seg span { display: block; text-align: center; padding: 8px; border-radius: 8px; font-weight: 600; color: var(--muted); }
.wide-seg input:checked + span { background: var(--ink); color: #fff; }
.wide-seg input:focus-visible + span { outline: 3px solid var(--brand); }
.lines { display: grid; gap: 8px; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) 76px 34px; gap: 8px; align-items: center; }
.line select, .line input { height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; min-width: 0; }
.order-total { display: flex; justify-content: space-between; font-weight: 600; padding-top: 10px; border-top: 1px solid var(--line); }
.order-total b { font-size: 1.15rem; }
.form-error { color: var(--bad); font-weight: 600; font-size: 0.88rem; background: var(--bad-soft); padding: 8px 12px; border-radius: 8px; }
.form-error[hidden] { display: none; }
.dform footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.toast {
  position: fixed; z-index: 100; right: 20px; bottom: 20px; max-width: calc(100% - 40px); padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: #fff; font-weight: 600; font-size: 0.9rem; box-shadow: 0 10px 30px rgb(0 0 0 / 0.25); animation: rise 0.25s ease-out;
}
.toast.warn { background: #78350f; }
.toast[hidden] { display: none; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.97); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---- Responsive -------------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-2 + .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .side {
    position: fixed; z-index: 50; inset: auto 0 0 0; height: auto; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid rgb(255 255 255 / 0.08);
  }
  .brand, .reset { display: none; }
  .menu { grid-template-columns: repeat(4, 1fr); width: 100%; gap: 2px; }
  .menu a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 0.7rem; position: relative; }
  .pill-count { position: absolute; top: 2px; right: calc(50% - 22px); margin: 0; min-width: 18px; height: 18px; font-size: 0.66rem; padding: 0 5px; }
  main { padding: 20px 14px 100px; }
  .page-head h1 { font-size: 1.5rem; }
  .kpi { padding: 14px 16px; }
  .kpi .value { font-size: 1.35rem; }
  .search { max-width: none; flex-basis: 100%; }
  .toast { left: 14px; right: 14px; bottom: 84px; }
  /* tables become cards */
  .ptable thead, .mtable thead { display: none; }
  .ptable, .ptable tbody, .mtable, .mtable tbody { display: block; }
  .ptable tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .ptable td { display: block; padding: 0; border: 0; }
  .ptable td[data-label="Kategori"], .ptable td[data-label="Maliyet"], .ptable td[data-label="Marj"] { display: none; }
  .ptable td[data-label="Ürün"] { grid-column: 1 / -1; }
  .ptable td[data-label="Satış"] { grid-row: 2; grid-column: 2; align-self: start; font-weight: 700; }
  .ptable td[data-label="Stok"] { grid-row: 2; grid-column: 1; text-align: left !important; min-width: 0; }
  .stock-top { justify-content: flex-start; }
  .stock-cell .bar { margin-left: 0; width: 100%; max-width: 220px; }
  .row-actions { grid-column: 1 / -1; text-align: left; padding-top: 6px !important; }
  .ptable tr.out td:first-child, .ptable tr.low td:first-child { box-shadow: none; }
  .ptable tr.out { box-shadow: inset 3px 0 0 #ef4444; }
  .ptable tr.low { box-shadow: inset 3px 0 0 #f59e0b; }
  .mtable tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .mtable td { display: block; padding: 0; border: 0; }
  .mtable td[data-label="Ürün"] { grid-row: 1; grid-column: 1; font-weight: 600; }
  .mtable td[data-label="Adet"] { grid-row: 1; grid-column: 2; }
  .mtable td[data-label="Zaman"] { grid-row: 2; grid-column: 1; color: var(--muted); font-size: 0.8rem; }
  .mtable td[data-label="Tür"] { grid-row: 2; grid-column: 2; }
  .mtable td[data-label="Not"] { grid-column: 1 / -1; font-size: 0.8rem; }
  .mtable td[data-label="Not"]:empty { display: none; }
  .two { grid-template-columns: 1fr; }
  .orders { grid-template-columns: 1fr; }
}
