/* Emerald POS — styles.css */
:root {
  --em-900: #022c22;
  --em-800: #064e3b;
  --em-700: #065f46;
  --em-600: #047857;
  --em-500: #059669;
  --em-400: #10b981;
  --em-200: #a7f3d0;
  --em-100: #d1fae5;
  --em-50:  #ecfdf5;
  --cream:  #f7f5ef;
  --paper:  #ffffff;
  --ink:    #1c2a25;
  --muted:  #5f6f69;
  --line:   #e3e0d6;
  --brass:  #a8803f;
  --amber:  #b45309;
  --amber-bg: #fef3c7;
  --red:    #b91c1c;
  --red-bg: #fee2e2;
  --blue:   #1d4ed8;
  --blue-bg:#dbeafe;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(2,44,34,.06), 0 4px 14px rgba(2,44,34,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--cream);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: Fraunces, Georgia, serif; color: var(--em-800); line-height: 1.15; margin: 0 0 .5rem; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
a { color: var(--em-600); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.right { text-align: right; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--em-800);
  background-image: radial-gradient(120% 140% at 0% 0%, #0b6b52 0%, var(--em-800) 55%, var(--em-900) 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 18px 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.brand span { font-family: Fraunces, Georgia, serif; font-size: 1.3rem; font-weight: 700; letter-spacing: .2px; }
.brand em { font-style: normal; color: var(--em-200); font-weight: 600; }
.topnav { display: none; gap: 4px; }
.topnav a { color: var(--em-100); text-decoration: none; padding: 8px 14px; border-radius: 999px; font-weight: 500; }
.topnav a.active, .topnav a:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ---------- bottom tabs (phones) ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--paper); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: .68rem; color: var(--muted); text-decoration: none; padding: 4px 0; font-weight: 500; white-space: nowrap;
}
.tabbar .ico { font-size: 1.25rem; line-height: 1.2; }
.tabbar a.active { color: var(--em-600); }
.tabbar a.tab-main .ico {
  background: var(--em-500); color: #fff; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; margin-top: -22px; box-shadow: 0 4px 12px rgba(5,150,105,.45);
  border: 3px solid var(--paper);
}
.tabbar a.tab-main { color: var(--em-700); }

@media (min-width: 900px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  body { padding-bottom: 30px; }
}

/* ---------- layout ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 18px 16px 30px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 700px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.spacer { flex: 1; }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 800px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.tile .label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.tile .value { font-family: Fraunces, Georgia, serif; font-size: 1.65rem; font-weight: 700; color: var(--em-800); margin-top: 2px; }
.tile .sub { font-size: .82rem; color: var(--muted); }
.tile.feature { background: linear-gradient(150deg, var(--em-700), var(--em-900)); border-color: transparent; }
.tile.feature .label, .tile.feature .sub { color: var(--em-200); }
.tile.feature .value { color: #fff; }

/* ---------- forms ---------- */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  padding: 11px 12px; border: 1px solid #cfcabd; border-radius: 10px; background: #fff;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--em-500); box-shadow: 0 0 0 3px rgba(16,185,129,.2); }
.price-input { font-family: Fraunces, Georgia, serif; font-size: 1.5rem; font-weight: 700; color: var(--em-800); }
.hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  padding: 11px 16px; border-radius: 10px; border: 1px solid transparent;
  background: var(--em-500); color: #fff; transition: transform .05s, background .15s;
}
.btn:hover { background: var(--em-600); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: var(--paper); color: var(--em-700); border-color: #cfcabd; }
.btn.secondary:hover { background: var(--em-50); }
.btn.ghost { background: transparent; color: var(--em-700); padding: 8px 10px; }
.btn.danger { background: var(--paper); color: var(--red); border-color: #f0c4c4; }
.btn.amber { background: var(--amber); }
.btn.big { padding: 15px 20px; font-size: 1.05rem; width: 100%; }
.btn.small { padding: 7px 11px; font-size: .88rem; }

/* ---------- chips / badges ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  border: 1px solid #cfcabd; background: var(--paper); color: var(--ink);
  border-radius: 999px; padding: 6px 13px; font: inherit; font-size: .88rem; cursor: pointer; font-weight: 500;
}
.chip.on { background: var(--em-700); border-color: var(--em-700); color: #fff; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.badge.available { background: var(--em-100); color: var(--em-700); }
.badge.hold { background: var(--amber-bg); color: var(--amber); }
.badge.sold { background: var(--blue-bg); color: var(--blue); }
.badge.removed { background: #eee; color: #666; }
.badge.warn { background: var(--red-bg); color: var(--red); }
.badge.legacy { background: #efe9dc; color: #7a6332; }

/* ---------- item grid ---------- */
.items { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .items { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .items { grid-template-columns: repeat(4, 1fr); } }
.item-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  text-decoration: none; color: inherit; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.item-card .ph { aspect-ratio: 4 / 3; background: #ece8dd center / cover no-repeat; display: grid; place-items: center; color: #b3ab98; font-size: 2rem; position: relative; }
.item-card .ph .badge { position: absolute; top: 8px; left: 8px; }
.item-card .body { padding: 10px 11px 12px; }
.item-card .code { font-size: .72rem; color: var(--muted); font-weight: 600; letter-spacing: .03em; }
.item-card .title { font-weight: 600; font-size: .93rem; margin: 2px 0 4px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-card .price { font-family: Fraunces, Georgia, serif; font-weight: 700; color: var(--em-700); font-size: 1.15rem; }
.item-card .meta { font-size: .76rem; color: var(--muted); }

/* ---------- photos ---------- */
.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.photo-strip .ph {
  flex: 0 0 auto; width: 108px; height: 108px; border-radius: 10px; background: #ece8dd center / cover no-repeat;
  position: relative; scroll-snap-align: start; border: 1px solid var(--line);
}
.photo-strip .ph .x {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: none;
  background: rgba(0,0,0,.6); color: #fff; font-size: 15px; cursor: pointer; line-height: 1;
}
.photo-strip.big .ph { width: min(78vw, 420px); height: min(58vw, 315px); }
.add-photo {
  flex: 0 0 auto; width: 108px; height: 108px; border-radius: 10px; border: 2px dashed var(--em-400);
  background: var(--em-50); color: var(--em-700); display: grid; place-items: center; text-align: center;
  font-weight: 600; font-size: .85rem; cursor: pointer; padding: 6px;
}
.camera-hero {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 2px dashed var(--em-400); background: var(--em-50); border-radius: var(--radius);
  padding: 34px 16px; cursor: pointer; text-align: center; color: var(--em-800);
}
.camera-hero .big-ico { font-size: 2.6rem; line-height: 1; }
.camera-hero strong { font-size: 1.1rem; }

.ai-banner { border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin: 12px 0 4px; display: flex; gap: 8px; align-items: flex-start; }
.ai-banner.working { background: var(--em-50); color: var(--em-700); }
.ai-banner.done { background: var(--em-100); color: var(--em-800); }
.ai-banner.err { background: var(--red-bg); color: var(--red); }
.ai-banner.standout { background: #fff7e6; color: #7a4d00; border: 1px solid #f3d9a4; }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; flex: 0 0 auto; margin-top: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tables / lists ---------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 9px 8px; border-bottom: 1px solid #f0ede5; vertical-align: top; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }
.list-row { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid #f0ede5; text-decoration: none; color: inherit; }
.list-row:last-child { border-bottom: none; }
.list-row .thumb { width: 54px; height: 54px; border-radius: 8px; background: #ece8dd center / cover no-repeat; flex: 0 0 auto; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-weight: 500; font-size: .95rem; color: var(--ink); margin: 0; }
.check input { width: 22px; height: 22px; accent-color: var(--em-500); flex: 0 0 auto; }

.platforms { display: grid; gap: 8px; }
.platform { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.platform .st { font-size: .8rem; color: var(--muted); }

.price-big { font-family: Fraunces, Georgia, serif; font-size: 2.1rem; font-weight: 700; color: var(--em-700); line-height: 1; }
.code-big { font-family: ui-monospace, Menlo, monospace; font-weight: 700; color: var(--em-800); background: var(--em-50); border: 1px solid var(--em-200); padding: 3px 9px; border-radius: 8px; }

.daily-text { background: #10231d; color: #d1fae5; border-radius: 12px; padding: 14px; font-family: ui-monospace, Menlo, monospace; font-size: .88rem; white-space: pre-wrap; }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty .big-ico { font-size: 2.2rem; }

.success-hero {
  background: linear-gradient(150deg, var(--em-600), var(--em-800)); color: #fff; border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px;
}
.success-hero h2 { color: #fff; margin: 0; }
.success-hero .btn.secondary { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.35); }

.modal-back { position: fixed; inset: 0; background: rgba(2,44,34,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 700px) { .modal-back { align-items: center; } }
.modal { background: var(--paper); width: 100%; max-width: 480px; border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 90vh; overflow-y: auto; }
@media (min-width: 700px) { .modal { border-radius: 18px; } }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--em-900); color: #fff; padding: 11px 18px; border-radius: 999px; font-weight: 500; font-size: .92rem;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 60; max-width: 92vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }

.login-wrap { min-height: 70vh; display: grid; place-items: center; }
.login { width: 100%; max-width: 360px; text-align: center; }
.login input { text-align: center; font-size: 1.6rem; letter-spacing: .4em; }

/* ---------- printable tags ---------- */
.tags-sheet { display: flex; flex-wrap: wrap; gap: 12px; }
.tag {
  width: 3.5in; height: 2.25in; border: 1.5px solid var(--em-800); border-radius: 10px; padding: .14in .18in;
  background: #fff; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden;
  page-break-inside: avoid; break-inside: avoid;
}
.tag .tag-top { display: flex; justify-content: space-between; align-items: center; font-size: 9pt; color: var(--em-800); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.tag .tag-title { font-weight: 600; font-size: 10.5pt; line-height: 1.2; max-height: 2.4em; overflow: hidden; color: #111; }
.tag .tag-price { font-family: Fraunces, Georgia, serif; font-size: 26pt; font-weight: 700; color: #111; line-height: 1; }
.tag .tag-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; }
.tag svg.bc { height: .62in; width: auto; max-width: 1.9in; }
.tag .tag-cond { font-size: 8pt; color: #444; }

@media print {
  @page { size: letter; margin: .35in; }
  body { background: #fff; padding: 0; }
  .no-print, .topbar, .tabbar, .toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .tag { border-color: #000; }
}

/* ---------- full-screen photo viewer ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 80; background: #03140f;
  display: flex; align-items: center; justify-content: center;
  padding: calc(60px + env(safe-area-inset-top)) 8px calc(56px + env(safe-area-inset-bottom));
}
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; -webkit-touch-callout: default; user-select: auto; }
.viewer-close {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 14px;
  width: 48px; height: 48px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.18); color: #fff; font-size: 22px; font-weight: 700;
}
.viewer-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 46px; height: 64px; border: none; border-radius: 10px; cursor: pointer;
  background: rgba(255,255,255,.14); color: #fff; font-size: 34px; line-height: 1;
}
.viewer-nav.prev { left: 8px; }
.viewer-nav.next { right: 8px; }
.viewer-foot {
  position: absolute; bottom: calc(14px + env(safe-area-inset-bottom)); left: 0; right: 0;
  display: flex; justify-content: center; gap: 14px; color: var(--em-200); font-size: .85rem;
}

/* ---------- online hold alert banner ---------- */
.hold-banner {
  position: fixed; left: 10px; right: 10px; top: calc(62px + env(safe-area-inset-top)); z-index: 45;
  background: var(--red); color: #fff; text-decoration: none; padding: 13px 16px; border-radius: 14px;
  box-shadow: 0 6px 20px rgba(185,28,28,.45); font-size: .95rem; text-align: center;
  animation: holdPulse 1.2s ease-in-out infinite;
}
@keyframes holdPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.025); } }
@media (min-width: 900px) { .hold-banner { left: 50%; right: auto; transform: translateX(-50%); width: 560px; animation: none; } }
