:root {
  --navy: #102a43;
  --navy-2: #183e61;
  --blue: #1d5fd1;
  --blue-2: #174ca5;
  --soft: #f5f7fb;
  --line: #e4e8ef;
  --text: #1d2939;
  --muted: #667085;
  --green: #168a5b;
  --red: #d92d20;
  --orange: #f59e0b;
  --shadow: 0 16px 40px rgba(16, 42, 67, .09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background: var(--soft);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 28px;
  color: #fff;
  background: rgba(16, 42, 67, .98);
  border-bottom: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(12px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
}
.brand-logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #0d2238, #1d5fd1);
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 12px;
  font-weight: 900;
  font-size: 20px;
  font-style: italic;
}
.brand strong, .brand small { display: block; }
.brand small { margin-top: 3px; color: #c8d8e8; font-size: 12px; }
.menu-toggle {
  display: none;
  border: 0;
  color: #fff;
  background: transparent;
  font-size: 24px;
}
.main-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.main-nav button, .admin-sidebar button {
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  color: #d9e3ed;
  background: transparent;
  font-weight: 800;
}
.main-nav button:hover, .main-nav button.active { color: #fff; background: rgba(255,255,255,.12); }
.admin-link { background: var(--blue) !important; color: #fff !important; }
#cartCount {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  margin-left: 5px;
  color: var(--navy);
  background: var(--orange);
  border-radius: 999px;
  font-size: 12px;
}

main { width: min(1240px, calc(100% - 32px)); margin: 28px auto 70px; }
.route { display: none; }
.route.active { display: block; }
.hero {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 32px;
  align-items: center;
  margin-bottom: 22px;
  padding: 42px;
  color: #fff;
  border-radius: 24px;
  background:
    radial-gradient(circle at 82% 16%, rgba(92, 171, 255, .35), transparent 26%),
    linear-gradient(120deg, #0d2238, #155999);
  box-shadow: var(--shadow);
}
.hero h1 {
  max-width: 840px;
  margin: 12px 0 16px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.05;
  letter-spacing: -.04em;
}
.hero p { max-width: 760px; margin: 0; color: #d6e7f8; line-height: 1.7; }
.hero-logo {
  width: min(380px, 80vw);
  margin: 0 0 16px;
  filter: invert(1) brightness(1.8) drop-shadow(0 10px 22px rgba(0,0,0,.22));
}
.pill {
  display: inline-flex;
  padding: 8px 11px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  color: #9dd2ff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.hero-card {
  padding: 22px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 18px;
  background: rgba(255,255,255,.09);
}
.hero-card strong { display: block; margin-bottom: 12px; }
.hero-card ol { margin: 0; padding-left: 20px; color: #e5eff9; line-height: 1.8; }

.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}
.filters {
  display: grid;
  grid-template-columns: 1fr 220px 220px;
  gap: 14px;
  margin-bottom: 28px;
  padding: 18px;
}
.field label, .form label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}
input, select, textarea {
  width: 100%;
  border: 1px solid #d0d5dd;
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  background: #fff;
  outline: 0;
}
input:focus, select:focus, textarea:focus {
  border-color: #7ba8ee;
  box-shadow: 0 0 0 3px rgba(29, 95, 209, .12);
}
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 26px 0 16px;
}
.section-title h1, .section-title h2 { margin: 0 0 6px; letter-spacing: -.03em; }
.section-title p, .muted { margin: 0; color: var(--muted); line-height: 1.6; }

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.product-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(16,42,67,.05);
}
.product-image {
  position: relative;
  height: 250px;
  display: grid;
  place-items: center;
  padding: 18px;
  background: linear-gradient(#fff, #f9fbff);
}
.product-image > img {
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  object-fit: contain;
}
.product-card.out .product-image img { opacity: .35; filter: grayscale(1) blur(1px); }
.out-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--red);
  font-size: 24px;
  font-weight: 1000;
  letter-spacing: .12em;
}
.product-body { padding: 16px; border-top: 1px solid var(--line); }
.code { color: var(--blue); font-size: 12px; font-weight: 900; }
.product-body h3 { min-height: 42px; margin: 6px 0 8px; font-size: 16px; line-height: 1.35; }
.description { min-height: 38px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.product-meta { display: flex; align-items: end; justify-content: space-between; gap: 10px; margin-top: 14px; }
.price { font-size: 22px; font-weight: 950; }
.stock { color: var(--green); font-size: 12px; font-weight: 850; }
.stock.no { color: var(--red); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 850;
}
.btn.primary { color: #fff; background: var(--blue); }
.btn.primary:hover { background: var(--blue-2); }
.btn.light { color: var(--navy); background: #eef2f7; }
.btn.danger { color: #fff; background: var(--red); }
.btn.small { padding: 8px 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.danger-text { color: #ffb4ae !important; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; vertical-align: middle; }
th { color: var(--muted); background: #f8fafc; font-size: 12px; text-transform: uppercase; white-space: nowrap; }
.qty-input { width: 86px; padding: 8px; }
.note-input { min-width: 160px; padding: 8px; }
.empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.total-panel {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  padding: 16px;
  background: #f8fafc;
  border-top: 1px solid var(--line);
}
.total-panel strong { color: var(--navy); }

.split {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 18px;
}
.split .card, .auth-card { padding: 26px; }
.info-card p { color: var(--muted); line-height: 1.65; }
.form { display: grid; gap: 14px; margin-top: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 10px !important; }
.checkbox input { width: auto; }
.auth-route { display: none; min-height: 62vh; place-items: center; }
.auth-route.active { display: grid; }
.auth-card { width: min(520px, 100%); }

.admin-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 18px;
}
.admin-sidebar {
  align-self: start;
  display: grid;
  gap: 8px;
  padding: 16px;
  background: var(--navy);
  color: #fff;
}
.admin-sidebar strong { padding: 8px 10px 12px; }
.admin-sidebar button {
  text-align: left;
  color: #c8d8e8;
}
.admin-sidebar button.active, .admin-sidebar button:hover { color: #fff; background: var(--navy-2); }
.admin-tab { display: none; }
.admin-tab.active { display: block; }
.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.settings-card { padding: 18px; }
.settings-card h3 { margin: 0 0 12px; }
.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 14px;
}
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--navy);
  font-size: 13px;
  font-weight: 800;
}
.chip button {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--red);
  font-size: 12px;
  line-height: 1;
}
.image-preview {
  min-height: 88px;
  display: grid;
  place-items: center;
  border: 1px dashed #b8c4d6;
  border-radius: 12px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}
.image-preview img {
  width: 96px;
  height: 96px;
  object-fit: contain;
}
.status {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}
.status.ok { color: #087443; background: #dff8eb; }
.status.no { color: #a12119; background: #fee4e2; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

dialog {
  width: min(620px, calc(100% - 24px));
  border: 0;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(9, 25, 41, .62); backdrop-filter: blur(5px); }
.dialog-body { padding: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

#toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  transform: translateY(22px);
  opacity: 0;
  max-width: min(420px, calc(100% - 32px));
  padding: 14px 18px;
  color: #fff;
  background: var(--navy);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: .22s;
  pointer-events: none;
  font-weight: 850;
}
#toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 1100px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
  .hero { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app-header { align-items: flex-start; flex-wrap: wrap; padding: 12px 16px; }
  .menu-toggle { display: block; margin-left: auto; }
  .main-nav { display: none; width: 100%; flex-direction: column; align-items: stretch; }
  .main-nav.open { display: flex; }
  .filters, .split, .admin-shell { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .section-title { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 520px) {
  main { width: min(100% - 18px, 1240px); margin-top: 14px; }
  .hero { padding: 26px; }
  .product-grid, .form-grid { grid-template-columns: 1fr; }
  .product-image { height: 280px; }
}
