/* ------------------------------------------------------------------
   Tokens: cool paper, deep ink, spruce accent for the store,
   slate panel for admin. System fonts so it works fully offline.
------------------------------------------------------------------- */
:root {
  --paper: #f5f6f3;
  --ink: #21252c;
  --muted: #6b7280;
  --line: #dcdfd9;
  --accent: #2e6b4f;      /* spruce green - actions */
  --accent-ink: #ffffff;
  --warn-bg: #fdf3e0;
  --warn-ink: #8a5a00;
  --danger: #a33030;
  --card: #ffffff;
  --admin-bg: #232830;
  --admin-panel: #2b313b;
  --radius: 6px;
  font-size: 16px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; letter-spacing: -0.01em; line-height: 1.2; }
h1 { font-size: 1.9rem; margin: 0 0 1rem; }
h2 { font-size: 1.3rem; margin: 1.5rem 0 .6rem; }

/* ---------- Store chrome ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 1.2rem; background: var(--card); border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.topbar .brand {
  font-family: Georgia, serif; font-size: 1.25rem; color: var(--ink); font-weight: 700;
}
.topbar nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.topbar nav a { color: var(--ink); }
.pill {
  background: var(--accent); color: var(--accent-ink) !important;
  padding: .3rem .8rem; border-radius: 999px;
}
.pill:hover { text-decoration: none; filter: brightness(1.1); }
.store-main { max-width: 1000px; margin: 0 auto; padding: 1.5rem 1.2rem 3rem; }
.site-foot {
  border-top: 1px solid var(--line); padding: 1.2rem; text-align: center; color: var(--muted);
}

/* ---------- Admin chrome ---------- */
body.admin { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--admin-bg); color: #cfd5dd;
  display: flex; flex-direction: column; padding: 1rem 0;
}
.sidebar .brand { padding: 0 1.2rem 1rem; font-family: Georgia, serif; font-size: 1.15rem; color: #fff; }
.sidebar .brand span { display: block; font-size: .75rem; letter-spacing: .15em; text-transform: uppercase; color: #8b93a0; font-family: system-ui, sans-serif; }
.sidebar nav { display: flex; flex-direction: column; }
.sidebar nav a { color: #cfd5dd; padding: .55rem 1.2rem; }
.sidebar nav a:hover { background: var(--admin-panel); text-decoration: none; }
.sidebar nav a.current { background: var(--admin-panel); color: #fff; border-left: 3px solid var(--accent); padding-left: calc(1.2rem - 3px); }
.sidebar nav a.back { margin-top: 1rem; color: #8b93a0; }
.sidebar-foot { margin-top: auto; padding: 1rem 1.2rem 0; font-size: .85rem; color: #8b93a0; }
.sidebar-foot a { color: #cfd5dd; }
.admin-main { flex: 1; padding: 1.5rem 2rem 3rem; max-width: 1100px; }

/* ---------- Components ---------- */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.flash.ok { background: #e4efe8; color: #1d4d38; }
.flash.err { background: #f7e3e3; color: var(--danger); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.card img, .card .noimg { width: 100%; aspect-ratio: 4/3; object-fit: cover; background: #e8eae4; }
.card .noimg { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .85rem; }
.card .body { padding: .8rem; display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.card .name { font-weight: 600; color: var(--ink); }
.card .price { font-family: Georgia, serif; font-size: 1.1rem; }
.card .stockline { font-size: .8rem; color: var(--muted); margin-top: auto; }

button, .btn {
  display: inline-block; background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: var(--radius); padding: .5rem 1rem; font-size: .95rem;
  cursor: pointer; font-family: inherit;
}
button:hover, .btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
button:disabled { background: var(--muted); cursor: not-allowed; }

form.stack { display: flex; flex-direction: column; gap: .8rem; max-width: 480px; }
label { font-size: .9rem; font-weight: 600; display: block; margin-bottom: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=file], textarea, select {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit; background: var(--card);
}
textarea { min-height: 110px; resize: vertical; }

table.list { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.list th, table.list td { text-align: left; padding: .55rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
table.list tr:last-child td { border-bottom: 0; }
table.list img.thumb { width: 48px; height: 36px; object-fit: cover; border-radius: 3px; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; }
.badge.open, .badge.pending { background: var(--warn-bg); color: var(--warn-ink); }
.badge.answered, .badge.paid, .badge.shipped { background: #e2ecf7; color: #1e4e79; }
.badge.closed, .badge.delivered { background: #e4efe8; color: #1d4d38; }
.badge.cancelled { background: #f0f0f0; color: var(--muted); }
.badge.low { background: #f7e3e3; color: var(--danger); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.stat .n { font-family: Georgia, serif; font-size: 1.7rem; }
.stat .l { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.msg { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: .8rem; }
.msg.staff { border-left: 3px solid var(--accent); }
.msg .who { font-size: .82rem; color: var(--muted); margin-bottom: .3rem; }

.product-page { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.product-page img, .product-page .noimg {
  width: 100%; border-radius: var(--radius); border: 1px solid var(--line);
  aspect-ratio: 4/3; object-fit: cover; background: #e8eae4;
}
.thumbs { display: flex; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }
.thumb-btn {
  padding: 0; border: 2px solid transparent; border-radius: var(--radius);
  background: none; cursor: pointer; width: 72px; overflow: hidden; line-height: 0;
}
.thumb-btn img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 4px; }
.thumb-btn.current { border-color: var(--accent); }
.gallery-admin { display: flex; gap: .8rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.gallery-admin .gitem { width: 140px; text-align: center; }
.gallery-admin .gitem img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }
.gallery-admin .gitem .cover-tag { display: block; font-size: .75rem; color: var(--accent); font-weight: 600; }

/* ---------- Lightbox (full-size photo view) ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 22, 26, .92);
  display: flex; align-items: center; justify-content: center;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 92vw; max-height: 92vh; width: auto; height: auto;
  aspect-ratio: auto; object-fit: contain; border: 0; border-radius: 4px; background: none;
}
.lb-close, .lb-nav {
  position: absolute; background: rgba(255,255,255,.12); color: #fff;
  border: 0; border-radius: 999px; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.lb-close { top: 1rem; right: 1rem; width: 44px; height: 44px; font-size: 1.6rem; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 48px; height: 48px; font-size: 2rem; }
.lb-prev { left: 1rem; }
.lb-next { right: 1rem; }
.lb-close:hover, .lb-nav:hover { background: rgba(255,255,255,.25); filter: none; }
.inline { display: inline; }

@media (max-width: 760px) {
  body.admin { flex-direction: column; }
  .sidebar { width: 100%; }
  .product-page { grid-template-columns: 1fr; }
  .admin-main { padding: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
