:root {
  --bg: #f3f4f6;
  --bg-card: #ffffff;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --text: #111827;
  --muted: #6b7280;
  --yellow: #f5d547;
  --yellow-hover: #f0cb2e;
  --black: #111111;
  --danger: #dc2626;
  --ok: #059669;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 8px 24px rgba(17, 24, 39, 0.06);
  --shadow-lg: 0 2px 4px rgba(17, 24, 39, 0.04), 0 16px 40px rgba(17, 24, 39, 0.08);
  --font: "Sora", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }

.app-shell {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.03);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 150px;
  text-decoration: none;
  color: inherit;
}
.brand strong { font-size: 15px; letter-spacing: 0.01em; }
.brand span {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}

.search-wrap {
  flex: 1;
  max-width: 640px;
  position: relative;
}
.search-wrap input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #fafafa;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.search-wrap input:focus {
  border-color: #111;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(245, 213, 71, 0.35);
}
.search-wrap .ico {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
  transition: transform .12s, background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover {
  border-color: #9ca3af;
  box-shadow: var(--shadow);
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--yellow);
  color: var(--black);
  border-color: #e6c63a;
}
.btn-primary:hover { background: var(--yellow-hover); }
.btn-dark {
  background: var(--black);
  color: #fff;
  border-color: var(--black);
}
.btn-dark:hover { background: #000; }
.btn-danger {
  background: #fff;
  border-color: #fecaca;
  color: var(--danger);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--muted);
}
.btn-sm { padding: 7px 12px; font-size: 12px; }

.page {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.page-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -0.02em;
}
.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.product-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-align: left;
  padding: 0;
  width: 100%;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  text-decoration: none;
  color: inherit;
}
.product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: #d1d5db;
}
.product-card .thumb {
  aspect-ratio: 1;
  background: #f3f4f6;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.product-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.product-card .thumb .ph {
  color: #9ca3af;
  font-size: 12px;
  font-family: var(--mono);
}
.product-card .body {
  padding: 14px 16px 16px;
  display: grid;
  gap: 10px;
}
.product-card .name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  min-height: 2.7em;
}
.product-card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  border: 1px solid var(--line);
  color: #374151;
}
.pill.ok {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: var(--ok);
}

.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fafafa;
}

.form-grid { display: grid; gap: 14px; }
.field label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: #fff;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(245, 213, 71, 0.35);
}
.field textarea { min-height: 90px; resize: vertical; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.detail-layout {
  display: grid;
  grid-template-columns: minmax(240px, 360px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.gallery {
  padding: 16px;
}
.gallery-main {
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: #f3f4f6;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}
.gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gallery-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.gallery-thumbs button {
  width: 64px;
  height: 64px;
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  background: #f3f4f6;
}
.gallery-thumbs button.active { border-color: var(--yellow); }
.gallery-thumbs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.panel {
  padding: 20px;
}
.panel + .panel { margin-top: 16px; }
.panel h2 {
  margin: 0 0 14px;
  font-size: 15px;
}
.panel h3 {
  margin: 0 0 12px;
  font-size: 14px;
}

.size-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.size-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0 8px 10px 0;
  font-weight: 600;
}
.size-table td {
  padding: 10px 8px 10px 0;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}
.size-table input {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #fff;
  font-family: var(--mono);
  font-size: 12px;
}
.size-table .stock {
  font-family: var(--mono);
  font-weight: 600;
}
.stock-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}
.icon-btn:hover { border-color: #111; background: var(--yellow); }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(800px 400px at 20% 0%, rgba(245, 213, 71, 0.18), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(400px, 100%);
  padding: 28px;
  border-radius: 20px;
}
.login-card h1 { margin: 0 0 6px; font-size: 24px; }
.login-card p { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-card .field { margin-bottom: 12px; }
.login-card .btn { width: 100%; margin-top: 8px; }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 50;
  padding: 12px 16px;
  border-radius: 12px;
  background: #111;
  color: #fff;
  font-size: 13px;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  animation: rise .2s ease;
}
.toast.err { background: #991b1b; }
.toast.ok { background: #111; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}
.back-link:hover { color: var(--text); }

.pager {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  align-items: center;
}

@media (max-width: 900px) {
  .detail-layout { grid-template-columns: 1fr; }
  .brand span { display: none; }
  .row-2, .row-3 { grid-template-columns: 1fr; }
  .page { width: min(100% - 24px, 1180px); padding-top: 18px; }
}
