* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e3e8f0;
  --txt: #1e293b;
  --muted: #64748b;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --ok: #16a34a;
  --err: #dc2626;
  --warn: #ea580c;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--txt);
  padding: 16px;
  min-height: 100vh;
}

.wrap { max-width: 1020px; margin: 0 auto; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}
.topbar h1 { font-size: 22px; }
.badge {
  background: #e0e7ff; color: #3730a3;
  padding: 4px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px; margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.card h2 { font-size: 16px; margin-bottom: 14px; }

.card-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h2 { margin: 0; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }

label { font-size: 13px; font-weight: 600; color: #334155; }
.req { color: var(--err); }

input[type=text], input[type=number], select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px; background: #fff; color: var(--txt);
  outline: none; transition: .15s;
}
input:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
#searchUser { max-width: 240px; }

.table-wrap {
  border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; max-height: 340px; overflow-y: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }

thead th {
  position: sticky; top: 0; z-index: 1;
  background: #f8fafc; text-align: left;
  padding: 10px 12px; font-size: 12px;
  text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); border-bottom: 1px solid var(--line);
}

tbody td { padding: 8px 12px; border-bottom: 1px solid #f1f5f9; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

.w-check { width: 46px; text-align: center; }
.w-qty   { width: 130px; }
.w-unit  { width: 110px; }
.w-role  { width: 140px; }
.w-del   { width: 60px; text-align: center; }
td.w-check { text-align: center; }

input[type=checkbox] {
  width: 17px; height: 17px;
  accent-color: var(--brand); cursor: pointer;
}

/* product rows input */
#productBody input { padding: 8px 10px; font-size: 13px; }

.empty { text-align: center; color: var(--muted); padding: 26px !important; }
.hint  { font-size: 12px; color: var(--muted); margin-top: 10px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  padding: 12px 22px; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: .15s;
  font-family: inherit;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.primary:disabled { opacity: .6; cursor: not-allowed; }
.btn.ghost { background: #fff; border: 1px solid var(--line); color: #334155; }
.btn.ghost:hover { background: #f8fafc; }
.btn.small { padding: 8px 14px; font-size: 13px; background: #eff6ff; color: var(--brand); border: 1px solid #bfdbfe; }
.btn.small:hover { background: #dbeafe; }

.btn-del {
  background: #fee2e2; color: var(--err);
  border: none; width: 28px; height: 28px; border-radius: 8px;
  cursor: pointer; font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-del:hover { background: #fecaca; }

.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translate(-50%, 140%);
  background: #0f172a; color: #fff;
  padding: 12px 22px; border-radius: 10px;
  font-size: 14px; opacity: 0; transition: .3s;
  pointer-events: none; max-width: 90vw; z-index: 999;
  text-align: center; line-height: 1.5;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.success { background: var(--ok); }
.toast.error   { background: var(--err); }
.toast.warn    { background: var(--warn); }

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .w-qty  { width: 90px; }
  .w-unit { width: 70px; }
  .w-role { width: 90px; }
  #searchUser { max-width: 100%; width: 100%; }
}