:root {
    --plum: #2b1e3f;
    --plum-2: #3d2c57;
    --gold: #d9a43a;
    --gold-soft: #fbf1dc;
    --ink: #1e2230;
    --muted: #697086;
    --line: #e3e5eb;
    --bg: #f4f5f8;
    --surface: #ffffff;
    --ok: #1f8a6c;
    --ok-soft: #e3f4ee;
    --bad: #c4432f;
    --bad-soft: #fbe9e6;
    --warn: #a86a12;
    --warn-soft: #fdf2df;
    --radius: 10px;
    --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--plum-2); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Karkas ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
    width: 232px; flex: none; background: var(--plum); color: #d9d2e6;
    position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 12px 30px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 0 8px 14px; }
.brand-mark {
    width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
    border: 2px solid var(--gold); color: var(--gold); font-weight: 700; font-size: 18px;
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.nav-group { font-size: 12px; color: #9d91b3; margin: 16px 8px 4px; }
.side nav a {
    display: block; color: #e6e0f0; text-decoration: none; padding: 8px 10px;
    border-radius: 8px; font-size: 14px; border-left: 3px solid transparent;
}
.side nav a:hover { background: var(--plum-2); }
.side nav a.on { background: var(--plum-2); border-left-color: var(--gold); color: #fff; font-weight: 600; }

.main { flex: 1; min-width: 0; }
.top {
    display: flex; align-items: center; gap: 14px; padding: 12px 24px; background: var(--surface);
    border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.top h1 { font-size: 20px; margin: 0; flex: 1; }
.menu-btn { display: none; border: 0; background: none; font-size: 22px; cursor: pointer; }
.who { display: flex; align-items: center; gap: 12px; }
.who-name { text-decoration: none; color: var(--ink); font-weight: 600; font-size: 14px; text-align: right; line-height: 1.2; }
.who-name small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.who form { margin: 0; }
.content { padding: 22px 24px 60px; max-width: 1400px; }

/* ---------- Bloklar ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel > h2:first-child { margin-top: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.cols { display: grid; gap: 18px; grid-template-columns: 380px 1fr; align-items: start; }
.cols-2 { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; align-items: start; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat span { display: block; color: var(--muted); font-size: 13px; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat.good b { color: var(--ok); }
.stat.bad b { color: var(--bad); }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.alert.success { background: var(--ok-soft); border-color: #b6e0d2; color: #135d49; }
.alert.error { background: var(--bad-soft); border-color: #f0c2b9; color: #8c2717; }
.alert.warning { background: var(--warn-soft); border-color: #f0d7a8; color: #7a4c08; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty h2 { color: var(--ink); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eceef3; color: #474e63; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.gold { background: var(--gold-soft); color: #8a6414; }

/* ---------- Jadval ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: 13px; background: #fafbfc; }
tr:hover td { background: #fbfbfd; }
tfoot td { font-weight: 700; background: #fafbfc; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline; }
.row-low td { background: var(--bad-soft); }

/* ---------- Forma ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 4px; color: #3b4052; }
input, select, textarea {
    width: 100%; padding: 9px 11px; border: 1px solid #cfd3dc; border-radius: 8px;
    font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--plum-2); outline: none; box-shadow: 0 0 0 3px rgba(61,44,87,.12); }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; margin-bottom: 8px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 140px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: 8px; border: 1px solid var(--plum); background: var(--plum);
    color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--plum-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #2b1e0a; }
.btn.gold:hover { background: #c8932c; }
.btn.ghost { background: transparent; color: var(--plum); border-color: #cfc8da; }
.btn.ghost:hover { background: #f3f0f7; }
.btn.danger { background: transparent; color: var(--bad); border-color: #eab8ae; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.pager { display: flex; gap: 4px; margin-top: 14px; flex-wrap: wrap; }
.pager a, .pager b, .pager span { padding: 5px 10px; border-radius: 6px; border: 1px solid var(--line); text-decoration: none; font-size: 13px; }
.pager b { background: var(--plum); color: #fff; border-color: var(--plum); }

dl.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 14px; }
dl.kv dd { margin: 0; font-weight: 600; }

/* ---------- POS ---------- */
body.pos .content { max-width: none; padding: 14px; }
.pos-wrap { display: grid; grid-template-columns: 1fr 400px; gap: 14px; align-items: start; }
.pos-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.pos-bar input { max-width: 320px; }
.cat-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.cat-tabs button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 7px 14px; cursor: pointer; font: inherit; font-size: 14px; }
.cat-tabs button.on { background: var(--plum); color: #fff; border-color: var(--plum); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 0; cursor: pointer;
    text-align: left; font: inherit; overflow: hidden; display: flex; flex-direction: column;
}
.tile:hover { border-color: var(--gold); }
.tile:active { transform: scale(.98); }
.tile img, .tile .noimg { width: 100%; height: 96px; object-fit: cover; background: #f0eef4; display: grid; place-items: center; color: #b1a8c2; font-size: 28px; font-weight: 700; }
.tile .t-body { padding: 8px 10px; }
.tile .t-name { font-weight: 600; font-size: 14px; line-height: 1.25; min-height: 2.5em; }
.tile .t-price { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--plum-2); }
.tile .t-stock { font-size: 12px; color: var(--muted); }
.tile.out { opacity: .45; }

.cart { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); position: sticky; top: 74px; display: flex; flex-direction: column; max-height: calc(100vh - 90px); }
.cart-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.cart-items { overflow-y: auto; flex: 1; min-height: 120px; }
.cart-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.cart-row .cr-name { font-weight: 600; font-size: 14px; }
.cart-row .cr-sum { font-weight: 700; font-variant-numeric: tabular-nums; }
.qty { display: flex; align-items: center; gap: 4px; }
.qty button { width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 16px; }
.qty input { width: 64px; text-align: center; padding: 4px; }
.cart-foot { padding: 12px 14px; border-top: 1px solid var(--line); }
.total-line { display: flex; justify-content: space-between; margin: 4px 0; font-size: 14px; }
.grand { display: flex; justify-content: space-between; align-items: baseline; margin: 8px 0 12px; }
.grand b { font-size: 30px; font-variant-numeric: tabular-nums; color: var(--plum); }
.pay-types { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.pay-types button { padding: 9px 4px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font: inherit; font-weight: 600; font-size: 14px; }
.pay-types button.on { border-color: var(--plum); background: var(--plum); color: #fff; }
.change { background: var(--gold-soft); border-radius: 8px; padding: 8px 12px; display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 10px; }
.btn.pay { width: 100%; padding: 14px; font-size: 17px; }
.cust-results { border: 1px solid var(--line); border-radius: 8px; max-height: 160px; overflow-y: auto; margin-top: 4px; }
.cust-results div { padding: 7px 10px; cursor: pointer; font-size: 14px; border-bottom: 1px solid var(--line); }
.cust-results div:hover { background: #f5f3f8; }

/* ---------- Kirish ---------- */
body.login { display: grid; place-items: center; min-height: 100vh; background: var(--plum); }
.login-box { background: #fff; width: min(380px, 92vw); border-radius: 14px; padding: 30px; border-top: 5px solid var(--gold); }
.login-box h1 { font-size: 24px; margin-bottom: 4px; }

/* ---------- Moslashuvchan ---------- */
@media (max-width: 1100px) {
    .pos-wrap { grid-template-columns: 1fr; }
    .cart { position: static; max-height: none; }
    .cols, .cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .side { position: fixed; left: -250px; z-index: 50; transition: left .2s; }
    .side.open { left: 0; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
    .menu-btn { display: block; }
    .content { padding: 14px; }
    .top { padding: 10px 14px; }
    .who-name small { display: none; }
    .grid2, .grid3 { grid-template-columns: 1fr; }
    dl.kv { grid-template-columns: 1fr; }
    dl.kv dt { margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
