:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --fg: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #888888);
  --card: var(--tg-theme-secondary-bg-color, #f3f4f6);
  --accent: var(--tg-theme-button-color, #2f7fe0);
  --accent-fg: var(--tg-theme-button-text-color, #ffffff);
  --border: rgba(128, 128, 128, 0.25);
  --danger: #d64545;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--fg);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px;
}
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--bg); z-index: 5;
}
.brand { font-weight: 700; }
.stats { font-size: 12px; color: var(--hint); }
#tabs {
  display: flex; gap: 4px; overflow-x: auto; padding: 8px 10px;
  border-bottom: 1px solid var(--border); position: sticky; top: 49px; background: var(--bg); z-index: 4;
}
#tabs button {
  flex: 0 0 auto; border: none; background: var(--card); color: var(--fg);
  padding: 8px 12px; border-radius: 16px; font-size: 13px;
}
#tabs button.active { background: var(--accent); color: var(--accent-fg); }
main { padding: 12px; padding-bottom: 60px; }
.tab { display: none; }
.tab.active { display: block; }
.toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
input, select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--fg);
}
textarea { min-height: 70px; resize: vertical; }
label { display: block; margin: 10px 0 0; font-size: 13px; color: var(--hint); }
label input, label select, label textarea { margin-top: 4px; }
button { cursor: pointer; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); color: var(--fg); }
button.primary { background: var(--accent); color: var(--accent-fg); border: none; }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
button.icon { border: none; background: transparent; font-size: 18px; }
.grid { display: flex; flex-direction: column; gap: 8px; }
.card {
  background: var(--card); border-radius: 12px; padding: 10px 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.card .name { font-weight: 600; font-size: 14px; }
.card .meta { font-size: 12px; color: var(--hint); margin-top: 2px; }
.card .price { font-weight: 700; white-space: nowrap; font-size: 13px; }
.pill { font-size: 11px; padding: 1px 6px; border-radius: 8px; background: var(--accent); color: var(--accent-fg); margin-left: 6px; }
.pager { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.muted { color: var(--hint); font-size: 12px; }
h3 { margin: 14px 0 6px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: flex-end; z-index: 20; }
.modal.hidden, .toast.hidden { display: none; }
.modal-box { background: var(--bg); width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 700; }
.modal-body { padding: 12px 14px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: space-between; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--border); }
.row2 { display: flex; gap: 8px; }
.row2 > * { flex: 1; }
.filebtn { display: inline-block; background: var(--accent); color: var(--accent-fg); padding: 9px 14px; border-radius: 10px; margin-top: 8px; width: auto; }
.brand-preview { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.brand-preview img { height: 70px; border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 4px; }
.brand-preview .cert { position: relative; }
.brand-preview .cert button { position: absolute; top: -8px; right: -8px; background: var(--danger); color: #fff; border: none; border-radius: 50%; width: 22px; height: 22px; padding: 0; }
.bom-row { display: flex; gap: 6px; margin-top: 6px; }
.bom-row input { padding: 6px 8px; }
.bom-row .sec { flex: 0 0 26%; }
.bom-row .nm { flex: 1; }
.bom-row .qt { flex: 0 0 18%; }
.bom-row .del { flex: 0 0 auto; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #333; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50; font-size: 13px; }
