:root {
  --brand: #2563eb;
  --brand-dark: #1e40af;
  --brand-soft: #eff4ff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f6f8fb;
  --card: #ffffff;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap, .container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.inline { display: inline; }

/* ---------- Top bar ---------- */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 0 20px; height: 62px; display: flex; align-items: center; gap: 26px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; font-size: 14px; font-weight: 800; letter-spacing: .5px; }
.brand-name { font-size: 16px; }
.mainnav { display: flex; gap: 4px; margin-right: auto; }
.mainnav a { padding: 8px 12px; border-radius: 9px; color: var(--ink-2); font-weight: 500; font-size: 14px; }
.mainnav a:hover { background: var(--brand-soft); text-decoration: none; }
.mainnav a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.store-badge { background: var(--brand-soft); color: var(--brand-dark); padding: 5px 12px; border-radius: 999px; font-weight: 600; font-size: 13px; }
.user-name { color: var(--ink-2); font-weight: 500; font-size: 14px; }

/* ---------- Layout ---------- */
.page { padding: 28px 0 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; margin: 0 0 2px; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--muted); }
.section-title { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 30px 0 12px; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) { .grid-3, .grid-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- Stat tiles ---------- */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; }
.stat .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat.accent { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); border: none; color: #fff; }
.stat.accent .label, .stat.accent .sub { color: rgba(255,255,255,.85); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; font-size: 14px; cursor: pointer; font-family: inherit; transition: .12s; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: #fff; border-color: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafbfc; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Forms ---------- */
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--ink-2); }
.form-row .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-family: inherit; font-size: 14px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 90px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; align-items: center; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--brand-soft); color: var(--brand-dark); }
.badge-gray { background: #f1f5f9; color: var(--muted); }

/* ---------- Product grid ---------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
.product-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; transition: .15s; }
.product-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16,24,40,.1); }
.product-thumb { aspect-ratio: 1/1; background: #f1f5f9; display: grid; place-items: center; overflow: hidden; }
.product-thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-thumb .ph { color: #cbd5e1; font-size: 13px; font-weight: 600; }
.product-body { padding: 13px 14px 16px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.product-cat { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.product-name { font-weight: 600; font-size: 14px; color: var(--ink); line-height: 1.3; }
.product-price { font-weight: 800; font-size: 16px; margin-top: 4px; }
.product-actions { margin-top: auto; padding-top: 10px; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.filters form { display: flex; gap: 8px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.chip:hover { background: var(--bg); text-decoration: none; }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Flash ---------- */
.flash { padding: 12px 0; font-weight: 500; font-size: 14px; }
.flash-success { background: var(--green-soft); color: #166534; }
.flash-error { background: var(--red-soft); color: #991b1b; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #eef2ff, #f6f8fb 40%); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 34px 30px; }
.auth-brand { display: flex; align-items: center; gap: 11px; justify-content: center; margin-bottom: 6px; }
.auth-brand .brand-mark { width: 40px; height: 40px; font-size: 16px; }
.auth-title { text-align: center; font-size: 20px; font-weight: 800; margin: 8px 0 2px; }
.auth-sub { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: 14px; }
.auth-error { background: var(--red-soft); color: #991b1b; padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; }
.auth-hint { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); text-align: center; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 20px 0; }
.footer .wrap { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .big { font-size: 17px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.split-line { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
.pill-split { font-size: 13px; color: var(--muted); }
.pill-split b { color: var(--ink); }
.back-link { color: var(--muted); font-size: 14px; display: inline-block; margin-bottom: 10px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
hr.soft { border: none; border-top: 1px solid var(--line); margin: 18px 0; }
.kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.totals-box { background: var(--brand-soft); border-radius: 12px; padding: 14px 16px; }
.totals-box .kv { border-bottom-color: rgba(37,99,235,.15); }
