/* Shop POS — admin styles */
:root {
	--bg: #f4f1ea;
	--surface: #ffffff;
	--surface-2: #faf8f3;
	--line: #e3ddd0;
	--text: #1f2420;
	--muted: #6b7068;
	--brand: #1d5c41;      /* paan-leaf green */
	--brand-ink: #ffffff;
	--brand-soft: #e3efe7;
	--warn: #b4630a;
	--warn-soft: #fbf0e0;
	--bad: #b42318;
	--bad-soft: #fdecea;
	--good: #1d7a45;
	--radius: 12px;
	--shadow: 0 1px 2px rgba(30, 30, 20, .06), 0 4px 16px rgba(30, 30, 20, .06);
	--ur: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", serif;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color-scheme: light;
}
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #141714;
		--surface: #1c201c;
		--surface-2: #222722;
		--line: #2f352f;
		--text: #e8ebe6;
		--muted: #9aa197;
		--brand: #4fae80;
		--brand-ink: #0d1a12;
		--brand-soft: #1f3529;
		--warn: #e6a04b;
		--warn-soft: #3a2c17;
		--bad: #f07065;
		--bad-soft: #3d1d1a;
		--good: #5fc48a;
		--shadow: none;
		color-scheme: dark;
	}
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.ur { font-family: var(--ur); line-height: 2; font-size: .95em; }
.num { font-variant-numeric: tabular-nums; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Buttons & inputs ---------- */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-height: 40px; padding: 8px 14px; border-radius: 10px;
	border: 1px solid var(--line); background: var(--surface); cursor: pointer;
	text-decoration: none; color: var(--text); font-weight: 550; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--brand); }
.btn-danger { color: var(--bad); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: wait; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
input, select, textarea {
	display: block; width: 100%; margin-top: 4px; min-height: 42px; padding: 8px 12px;
	border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 15px;
}
input[dir="rtl"] { font-family: var(--ur); line-height: 1.9; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

.alert { padding: 10px 14px; border-radius: 10px; margin: 10px 0; font-size: 14px; }
.alert-bad { background: var(--bad-soft); color: var(--bad); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- Login ---------- */
.spos-login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); padding: 32px 26px; border-radius: 18px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.login-card h1 { margin: 10px 0 2px; font-size: 22px; }
.login-card .muted { margin: 0 0 18px; }
.brand-mark { color: var(--brand); }

/* ---------- App shell ---------- */
.topbar {
	position: sticky; top: 0; z-index: 20; background: var(--brand); color: var(--brand-ink);
	display: flex; align-items: center; gap: 12px; padding: 10px 16px;
}
.topbar h1 { font-size: 17px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .who { font-size: 13px; opacity: .85; }
.topbar a { color: inherit; font-size: 13px; opacity: .9; }
.tabs { display: flex; gap: 4px; padding: 8px 16px 0; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; position: sticky; top: 52px; z-index: 19; }
.tab { padding: 10px 14px; border: 0; background: none; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--brand); border-color: var(--brand); }
main.view { max-width: 1100px; margin: 0 auto; padding: 18px 16px 80px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.toolbar label { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.card-head h3 { margin: 0; font-size: 16px; flex: 1; min-width: 0; }
.card-body { padding: 0 14px 12px; }

.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; overflow: hidden; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.chip-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip-bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip-good { background: var(--brand-soft); color: var(--good); border-color: transparent; }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; font-weight: 700; }

/* Type rows inside a product */
.type-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.type-row .t-name { flex: 1 1 200px; font-weight: 600; }
.unit-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.unit-pill { font-size: 12px; padding: 3px 8px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.unit-pill b { font-variant-numeric: tabular-nums; }

/* Stock table */
.stock-table { width: 100%; border-collapse: collapse; }
.stock-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.stock-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.stock-table tr.low td { background: var(--warn-soft); }
.stock-table tr.neg td { background: var(--bad-soft); }
.stock-table .actions { text-align: right; white-space: nowrap; }
.stock-qty { font-weight: 700; font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
	.stock-table thead { display: none; }
	.stock-table, .stock-table tbody, .stock-table tr, .stock-table td { display: block; width: 100%; }
	.stock-table tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
	.stock-table td { padding: 2px 0; border: 0; }
	.stock-table .actions { text-align: left; padding-top: 8px; }
	.stock-table tr.low, .stock-table tr.neg { background: var(--warn-soft); }
	.stock-table tr.neg { background: var(--bad-soft); }
	.stock-table tr.low td, .stock-table tr.neg td { background: none; }
}

/* ---------- Modal (bottom sheet on phones) ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 14, 10, .45); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; padding: 16px 18px 6px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h2 { font-size: 18px; margin: 0; flex: 1; }
.modal-body { padding: 8px 18px 4px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px 18px; position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); }
.x { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; }
@media (max-width: 600px) {
	.modal-bg { place-items: end stretch; padding: 0; }
	.modal { max-width: none; border-radius: 18px 18px 0 0; max-height: 94vh; }
}

/* Unit editor */
.unit-edit { display: grid; grid-template-columns: 1.3fr .8fr 1fr auto auto; gap: 8px; align-items: end; padding: 8px 0; border-top: 1px dashed var(--line); }
.unit-edit label { margin: 0; font-size: 11px; }
.unit-edit .chk { display: flex; align-items: center; gap: 4px; font-size: 12px; padding-bottom: 10px; color: var(--muted); }
.unit-edit .chk input { width: auto; min-height: 0; margin: 0; }
@media (max-width: 520px) {
	.unit-edit { grid-template-columns: 1fr 1fr; }
}
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.hint { font-size: 12px; color: var(--muted); margin: -6px 0 12px; }
.preview { background: var(--brand-soft); color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 6px 0 12px; }

.img-pick { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.img-pick .thumb { width: 64px; height: 64px; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; z-index: 80; font-size: 14px; max-width: 90vw; }
.toast.bad { background: var(--bad); color: #fff; }

.moves { width: 100%; border-collapse: collapse; font-size: 13px; }
.moves td, .moves th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.plus { color: var(--good); font-weight: 700; }
.minus { color: var(--bad); font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; }
