/* Sparkline Jewels — black, white, champagne gold. Poppins throughout. */

/* ---------- Poppins (self-hosted: works offline and prints the same everywhere) ---------- */
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 300; font-display: swap; src: url(/fonts/poppins-latin-300-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/poppins-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/poppins-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/poppins-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 300; font-display: swap; src: url(/fonts/poppins-latin-ext-300-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+20A0-20AB, U+20AD-20C0, U+2113; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/poppins-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+20A0-20AB, U+20AD-20C0, U+2113; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/poppins-latin-ext-500-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+20A0-20AB, U+20AD-20C0, U+2113; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/poppins-latin-ext-600-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+20A0-20AB, U+20AD-20C0, U+2113; }

:root {
  --black: #000000;
  --white: #ffffff;
  --gold: #C39B63;
  --gold-hi: #d9b98a;
  --gold-deep: #8f6f43;
  --gold-wash: rgba(195, 155, 99, 0.13);
  --grey: #a7a7a7;
  --faint: #6e6e6e;
  --line: #262626;
  --line-2: #3a3a3a;
  --field: #0c0c0c;
  --panel: #0a0a0a;
  --profit: #62d39c;
  --loss: #ff6f6f;
  --warn: #ff9d5c;
  --radius: 12px;
  --top-h: 58px;
  --nav-h: 64px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--black); color: var(--white); }
body {
  font-family: 'Poppins', system-ui, sans-serif; font-size: 15px; line-height: 1.5; font-weight: 400;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  min-height: 100vh; min-height: 100dvh;
}
a { color: var(--gold); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.ic { width: 20px; height: 20px; flex: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 18px; line-height: 1.3; }
h3 { font-size: 15px; line-height: 1.35; }
.num, .money, td.r, .fig { font-variant-numeric: tabular-nums; }
.muted { color: var(--grey); }
.faint { color: var(--faint); }
.gold { color: var(--gold); }
.profit { color: var(--profit); }
.loss { color: var(--loss); }
.warn { color: var(--warn); }
.hide { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- shell ---------- */
#app { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: calc(var(--top-h) + var(--safe-t)); padding: var(--safe-t) 14px 0;
  display: flex; align-items: center; gap: 12px; background: rgba(0,0,0,0.92);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar .brand img.mark { height: 26px; width: auto; }
.topbar .brand img.word { height: 24px; width: auto; }
.topbar .spacer { flex: 1; }
.ver { font-size: 11px; color: var(--faint); letter-spacing: 0.02em; }
.iconbtn {
  width: 42px; height: 42px; display: inline-grid; place-items: center; border-radius: 50%;
  border: 1px solid transparent; background: none; cursor: pointer; color: var(--white);
}
.iconbtn:hover { border-color: var(--line-2); }
.iconbtn svg { width: 22px; height: 22px; }

.sidebar { display: none; }
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(0,0,0,0.95); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); font-size: 11px; font-weight: 500; position: relative;
}
.bottomnav a svg { width: 23px; height: 23px; }
.bottomnav a.on { color: var(--gold); }
.bottomnav a.on::before { content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; background: var(--gold); border-radius: 0 0 2px 2px; }

main#view { padding: 18px 16px calc(var(--nav-h) + var(--safe-b) + 28px); max-width: 1180px; margin: 0 auto; overflow-x: clip; }
/* grid and flex children may shrink below their content, so wide tables scroll inside their own box */
.detail-top > *, .piece-top > *, .stack > *, .grid > *, .kpis > *, .page-head > *, .col { min-width: 0; }
.only-narrow { display: none; }
@media (max-width: 759px) { .only-wide { display: none !important; } .only-narrow { display: block; } }

@media (min-width: 960px) {
  #app { display: grid; grid-template-columns: 236px 1fr; }
  .topbar { display: none; }
  .bottomnav { display: none; }
  .sidebar {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 28px 18px 18px;
    border-right: 1px solid var(--line); gap: 4px;
  }
  .sidebar .logo { display: block; padding: 0 10px 26px; }
  .sidebar .logo img { width: 170px; }
  .sidebar a.nav {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--grey); font-weight: 500;
  }
  .sidebar a.nav svg { width: 20px; height: 20px; }
  .sidebar a.nav:hover { color: var(--white); background: #0f0f0f; }
  .sidebar a.nav.on { color: var(--black); background: var(--gold); }
  .sidebar .foot { margin-top: auto; padding: 12px; display: flex; justify-content: space-between; align-items: center; }
  main#view { padding: 32px 36px 60px; }
}

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .t { min-width: 0; }
.page-head .sub { color: var(--grey); font-size: 14px; margin-top: 4px; }
.page-head .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--grey); font-size: 14px; margin-bottom: 10px; cursor: pointer; background: none; border: 0; padding: 4px 0; }
.back-link svg { width: 18px; height: 18px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line-2); background: transparent; color: var(--white);
  font-weight: 500; font-size: 14.5px; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--grey); }
.btn svg { width: 18px; height: 18px; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #000; font-weight: 600; }
.btn.gold:hover { background: var(--gold-hi); border-color: var(--gold-hi); }
.btn.danger { color: var(--loss); border-color: #4a2626; }
.btn.quiet { border-color: transparent; color: var(--grey); }
.btn.quiet:hover { color: var(--white); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.busy { opacity: .7; pointer-events: none; }

/* ---------- form fields ---------- */
.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fld > span, .lbl { font-size: 12.5px; color: var(--grey); font-weight: 500; }
.inp, select.inp, textarea.inp {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--field); color: var(--white); font-size: 16px; outline: none; appearance: none; -webkit-appearance: none;
}
textarea.inp { min-height: 84px; resize: vertical; line-height: 1.45; }
select.inp { padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--grey) 50%), linear-gradient(135deg, var(--grey) 50%, transparent 50%);
  background-position: calc(100% - 18px) 20px, calc(100% - 13px) 20px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.inp:focus { border-color: var(--gold); }
.inp.err { border-color: var(--loss); }
.inp[readonly] { color: var(--grey); }
.inp.auto { color: var(--gold); border-style: dashed; background: transparent; }
.inp-unit { position: relative; }
.inp-unit .inp { padding-right: 44px; }
.inp-unit .u { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 13px; pointer-events: none; }
.inp-pre { position: relative; }
.inp-pre .inp { padding-left: 34px; }
.inp-pre .p { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 14px; pointer-events: none; white-space: pre; }
.inp-pre[data-w="2"] .inp { padding-left: 42px; }
.inp-pre[data-w="3"] .inp { padding-left: 50px; }
.inp-pre[data-w="4"] .inp { padding-left: 58px; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .g4 { grid-template-columns: repeat(4, 1fr); } }
.span2 { grid-column: span 2; }
.hint { font-size: 12.5px; color: var(--faint); }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 0 12px; min-height: 40px; color: var(--grey); cursor: pointer; font-size: 13.5px; font-weight: 500; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--gold); color: #000; }
.fld .seg { align-self: flex-start; max-width: 100%; }
.fld .seg button { min-height: 44px; }
input::placeholder, textarea::placeholder { color: var(--faint); text-transform: none; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 14px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .tr { width: 42px; height: 24px; border-radius: 12px; background: #2a2a2a; position: relative; transition: background .15s; flex: none; }
.switch .tr::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .tr { background: var(--gold); }
.switch input:checked + .tr::after { transform: translateX(18px); }

/* ---------- chips, hallmarks ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line-2);
  background: none; color: var(--grey); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.chip .n { color: var(--faint); font-size: 12px; }
.chip.on { border-color: var(--gold); color: var(--gold); background: var(--gold-wash); }
.chip.on .n { color: var(--gold); }

.tag { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; border: 1px solid var(--line-2); color: var(--grey); white-space: nowrap; }
.tag.gold { border-color: var(--gold-deep); color: var(--gold); }
.tag.green { border-color: #24533c; color: var(--profit); }
.tag.red { border-color: #5a2a2a; color: var(--loss); }
.tag.warn { border-color: #5c3a22; color: var(--warn); }
.tag.white { border-color: #555; color: var(--white); }

/* the hallmark: purity stamped like a maker's punch */
.hm {
  display: inline-flex; align-items: center; justify-content: center; min-width: 38px; padding: 1px 7px; border: 1px solid var(--gold);
  border-radius: 3px; color: var(--gold); font-size: 12px; font-weight: 600; letter-spacing: .05em; line-height: 1.55; white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(195,155,99,.18);
}
.hm.solid { background: var(--gold); color: #000; }
.hm.big { font-size: 14px; padding: 3px 10px; }

/* ---------- surfaces ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--panel); overflow-wrap: break-word; }
.card + .card { margin-top: 14px; }
.card h2 { margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.stack > * + * { margin-top: 14px; }
.sep { height: 1px; background: var(--line); margin: 14px 0; }
.section-t { font-size: 13px; color: var(--grey); font-weight: 600; margin: 26px 0 10px; }
.empty { padding: 34px 16px; text-align: center; color: var(--grey); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.empty .btn { margin-top: 14px; }
.banner { border: 1px solid #5c3a22; color: var(--warn); border-radius: var(--radius); padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* ---------- lists ---------- */
.list { border-top: 1px solid var(--line); }
.row {
  display: grid; grid-template-columns: 58px 1fr auto; gap: 12px; align-items: center; padding: 12px 2px;
  border-bottom: 1px solid var(--line); cursor: pointer; color: inherit;
}
.row.nothumb { grid-template-columns: 1fr auto; }
.row.sel { grid-template-columns: 28px 58px 1fr auto; }
.row:hover { background: #070707; }
.row .main { min-width: 0; }
.row .t1 { font-weight: 500; display: flex; gap: 8px; align-items: center; min-width: 0; }
.row .t1 .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .t2 { font-size: 13px; color: var(--grey); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.row .t3 { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.row .aside { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.row .amt { font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .amt2 { font-size: 12.5px; color: var(--grey); white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .amt2.warn { color: var(--warn); }
.row .amt2.gold { color: var(--gold); }
.tick { width: 24px; height: 24px; border-radius: 6px; border: 1.5px solid var(--line-2); display: grid; place-items: center; }
.tick svg { width: 16px; height: 16px; opacity: 0; }
.row.picked .tick, .tick.on { background: var(--gold); border-color: var(--gold); color: #000; }
.row.picked .tick svg, .tick.on svg { opacity: 1; }
.row.picked { background: var(--gold-wash); }

.thumb { width: 58px; height: 58px; border-radius: 8px; overflow: hidden; background: #111; display: grid; place-items: center; color: var(--faint); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb svg { width: 22px; height: 22px; }

/* ---------- figures ---------- */
.figline { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; color: var(--white); }
.figline .fig { white-space: nowrap; }
.figline .k { color: var(--grey); margin-right: 4px; }
.figline .q { color: var(--grey); }
.figline .pc { color: var(--grey); margin-left: 4px; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--panel); cursor: pointer; min-width: 0; color: var(--white); display: block; }
.kpi .k { font-size: 12.5px; color: var(--grey); font-weight: 500; }
.kpi .v { font-size: 22px; font-weight: 300; margin-top: 6px; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi .v + .v { margin-top: 2px; font-size: 17px; }
.kpi .s { font-size: 12.5px; color: var(--faint); margin-top: 6px; }

/* the dark total strip: gold rule, big light numbers */
.total-strip { border-top: 1px solid var(--gold); padding: 16px 2px 4px; margin-top: 18px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 18px; }
@media (min-width: 760px) { .total-strip { grid-template-columns: repeat(4, 1fr); } }
.total-strip .k { font-size: 12.5px; color: var(--grey); font-weight: 500; }
.total-strip > div { min-width: 0; }
.total-strip .v { font-size: clamp(16px, 5.2vw, 21px); font-weight: 300; font-variant-numeric: tabular-nums; line-height: 1.25; overflow-wrap: anywhere; }
.total-strip .q { font-size: 13.5px; color: var(--grey); font-variant-numeric: tabular-nums; }
.total-strip .hero .v { color: var(--gold); font-weight: 400; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 -2px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 500; color: var(--grey); padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl td { padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl td .q { display: block; font-size: 12px; color: var(--grey); }
.tbl tr.on td { background: var(--gold-wash); }
.tbl tr.click { cursor: pointer; }
.tbl tfoot td { border-top: 1px solid var(--gold); border-bottom: 0; font-weight: 500; }

/* ---------- photo ---------- */
.photo-box {
  position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: var(--radius); border: 1px dashed var(--line-2);
  background: #070707; display: grid; place-items: center; overflow: hidden; cursor: pointer; color: var(--grey);
}
.photo-box.has { border-style: solid; border-color: var(--line); background: #fff; cursor: zoom-in; }
.photo-box img { width: 100%; height: 100%; object-fit: contain; display: block; }
.photo-box .ph { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13.5px; text-align: center; padding: 0 12px; }
.photo-box .ph svg { width: 30px; height: 30px; color: var(--gold); }
.photo-box .pb-acts { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; }
.pb-btn {
  display: inline-flex; align-items: center; gap: 6px; background: rgba(0,0,0,.78); color: #fff; border: 0; border-radius: 9px;
  padding: 7px 11px; font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit;
}
.pb-btn svg { width: 16px; height: 16px; }
.photo-box.busy::after { content: 'Uploading…'; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.7); color: var(--gold); font-size: 14px; }

/* ---------- zoomable viewer (full screen, or pinned while typing) ---------- */
.viewer { position: fixed; inset: 0; z-index: 90; background: #000; display: flex; flex-direction: column; padding-top: var(--safe-t); }
.viewer .vz { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #fff; touch-action: none; cursor: grab; }
.viewer .vz:active { cursor: grabbing; }
.viewer .vz img { position: absolute; left: 0; top: 0; max-width: none; max-height: none; transform-origin: 0 0; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }
.viewer .vbar { display: flex; align-items: center; gap: 6px; padding: 8px 10px calc(8px + var(--safe-b)); background: #000; border-top: 1px solid var(--line); }
.viewer .vbar .grow { flex: 1; }
.viewer .vhint { color: var(--faint); font-size: 12px; margin-left: 6px; }
.vbtn {
  min-width: 42px; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: transparent; color: #fff;
  font: 500 14px 'Poppins', sans-serif; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
}
.vbtn svg { width: 18px; height: 18px; }
.vbtn[data-act="vz-pin"] { border-color: var(--gold-deep); color: var(--gold); }
@media (max-width: 640px) { .viewer .vhint { display: none; } .vbtn span { display: none; } }
.viewer.pinned { inset: auto; top: 0; left: 0; right: 0; height: 42vh; padding-top: var(--safe-t); border-bottom: 2px solid var(--gold-deep); box-shadow: 0 10px 30px rgba(0,0,0,.6); }
.viewer.pinned .vbar { padding-bottom: 8px; }
.viewer.pinned .vhint { display: none; }
@media (max-width: 1099px) {
  body.pinned #app { padding-top: 42vh; }
  body.pinned .topbar { display: none; }
  html.pinned { scroll-padding-top: 46vh; }
}
@media (min-width: 1100px) {
  .viewer.pinned { top: 0; bottom: 0; left: auto; right: 0; width: 460px; height: auto; border-bottom: 0; border-left: 2px solid var(--gold-deep); }
  body.pinned main#view { margin-right: 460px; margin-left: 0; }
}
/* with the design open beside the form, stone lines use the compact layout */
@media (min-width: 760px) {
  body.pinned .stone { grid-template-columns: 1fr 1fr 1fr; }
  body.pinned .stone .d { grid-column: span 2; }
  body.pinned .purity-fields { grid-template-columns: 1fr 1fr; }
}
.design-help { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 4px 0 8px; }
.design-help .hint { flex: 1; min-width: 200px; }

/* ---------- photo library ---------- */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.lib-grid.page { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.lib-tile { display: flex; flex-direction: column; gap: 4px; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; cursor: pointer; text-align: left; color: inherit; font: inherit; }
.lib-tile:hover { border-color: var(--gold-deep); }
.lib-tile .im { display: block; aspect-ratio: 1; background: #fff; }
.lib-tile .im img { width: 100%; height: 100%; object-fit: contain; display: block; }
.lib-tile .nm { padding: 4px 9px 0; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-tile .us { padding: 0 9px 8px; font-size: 11.5px; color: var(--grey); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-tile .us.un { color: var(--warn); }
.lib-preview { position: relative; margin-top: 10px; border-radius: var(--radius); overflow: hidden; background: #fff; cursor: zoom-in; }
.lib-preview img { display: block; width: 100%; max-height: 300px; object-fit: contain; }
.lib-preview .pb-btn { position: absolute; right: 8px; bottom: 8px; pointer-events: none; }

/* ---------- quotation form ---------- */
.piece { border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: var(--panel); margin-top: 16px; }
.piece-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.piece-head h2 { font-size: 17px; }
.piece-top { display: grid; gap: 14px; }
@media (min-width: 760px) { .piece-top { grid-template-columns: 300px 1fr; } }
.purity { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 10px; }
.purity.on { border-color: var(--gold-deep); background: linear-gradient(0deg, rgba(195,155,99,.06), rgba(195,155,99,.06)); }
.purity-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.purity-head .grow { flex: 1; }
.quoted-toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--grey); background: none; border: 0; padding: 4px 0; }
.quoted-toggle .dot { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-2); display: grid; place-items: center; }
.purity.on .quoted-toggle { color: var(--gold); }
.purity.on .quoted-toggle .dot { border-color: var(--gold); }
.purity.on .quoted-toggle .dot::after { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); }
.purity-fields { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; align-items: end; }
@media (min-width: 760px) { .purity-fields { grid-template-columns: 150px 110px 140px 1fr; } }
.purity .figline { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
details.sec { border-top: 1px solid var(--line); margin-top: 16px; }
details.sec > summary { list-style: none; cursor: pointer; padding: 14px 0 4px; display: flex; align-items: center; gap: 10px; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary .t { font-weight: 600; font-size: 14.5px; }
details.sec > summary .s { color: var(--grey); font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.sec > summary .ic { width: 18px; height: 18px; color: var(--grey); transition: transform .15s; flex: none; }
details.sec[open] > summary .ic { transform: rotate(180deg); }
details.sec .body { padding: 10px 0 4px; }
.rates-grid { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
@media (min-width: 760px) { .rates-grid { grid-template-columns: repeat(4, 1fr); } }
.stone { display: grid; gap: 8px; grid-template-columns: 1fr 1fr 1fr; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: end; }
.stone .d { grid-column: span 2; }
@media (min-width: 760px) { .stone { grid-template-columns: 2fr 1fr 70px 90px 1fr 1fr 40px; } .stone .d { grid-column: auto; } }
.stone .x { align-self: center; }
.piece-sum { margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; display: grid; grid-template-columns: repeat(2, 1fr); overflow: hidden; }
@media (min-width: 760px) { .piece-sum { grid-template-columns: repeat(4, 1fr); } }
.piece-sum > div { padding: 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.piece-sum .k { font-size: 12px; color: var(--grey); }
.piece-sum .v { font-size: 17px; font-weight: 300; font-variant-numeric: tabular-nums; }
.piece-sum .q { font-size: 12.5px; color: var(--grey); font-variant-numeric: tabular-nums; }
.add-line { margin-top: 10px; }
.sticky-save {
  position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 10px); z-index: 20; margin-top: 22px;
  display: flex; gap: 10px; justify-content: flex-end; padding: 10px; border: 1px solid var(--line-2); border-radius: 14px;
  background: rgba(0,0,0,.9); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
@media (min-width: 960px) { .sticky-save { bottom: 16px; } }
.sticky-save .info { margin-right: auto; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.sticky-save .info .v { font-weight: 500; font-variant-numeric: tabular-nums; }
.sticky-save .info .k { font-size: 12px; color: var(--grey); }

/* ---------- detail pages ---------- */
.detail-top { display: grid; gap: 16px; }
@media (min-width: 860px) { .detail-top { grid-template-columns: 360px 1fr; align-items: start; } }
.big-photo { border-radius: var(--radius); overflow: hidden; background: #fff; border: 1px solid var(--line); cursor: zoom-in; }
.big-photo img { width: 100%; max-height: 420px; object-fit: contain; display: block; }
.big-photo.none { background: #070707; aspect-ratio: 4/3; display: grid; place-items: center; color: var(--faint); cursor: default; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.kv .k { color: var(--grey); }
.kv .v { text-align: right; font-variant-numeric: tabular-nums; }
.stages { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 14px; }
.stages .st { border-top: 3px solid var(--line-2); padding-top: 6px; font-size: 12px; color: var(--faint); }
.stages .st.done { border-color: var(--gold-deep); color: var(--grey); }
.stages .st.now { border-color: var(--gold); color: var(--gold); font-weight: 600; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.pay-line { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; align-items: center; }
.pay-line:last-child { border-bottom: 0; }

/* ---------- sheet / dialog ---------- */
.scrim { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.72); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-height: 88vh; overflow: auto; background: #0b0b0b; border: 1px solid var(--line-2); border-bottom: 0;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(var(--safe-b) + 18px);
}
@media (min-width: 700px) { .scrim { align-items: center; } .sheet { width: 520px; border-radius: 18px; border-bottom: 1px solid var(--line-2); padding-bottom: 18px; } }
.sheet h2 { margin-bottom: 6px; }
.sheet .txt { color: var(--grey); font-size: 14px; margin-bottom: 14px; }
.sheet .acts { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.sheet .opt { display: flex; width: 100%; align-items: center; gap: 12px; padding: 14px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; font-size: 15px; }
.sheet .opt:last-child { border-bottom: 0; }
.sheet .opt.on { color: var(--gold); }

.toasts { position: fixed; left: 0; right: 0; top: calc(var(--top-h) + var(--safe-t) + 10px); z-index: 95; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 960px) { .toasts { top: 20px; } }
body.printing .toasts { top: calc(var(--safe-t) + 70px); }
.toast { background: #151515; border: 1px solid var(--line-2); color: var(--white); padding: 11px 16px; border-radius: 12px; font-size: 14px; max-width: 520px; box-shadow: 0 10px 30px rgba(0,0,0,.6); pointer-events: auto; }
.toast.err { border-color: #6a2b2b; color: #ffd0d0; }
.toast.ok { border-color: var(--gold-deep); }

.spin { width: 22px; height: 22px; border: 2px solid var(--line-2); border-top-color: var(--gold); border-radius: 50%; animation: sp .8s linear infinite; display: inline-block; }
@keyframes sp { to { transform: rotate(360deg); } }
.loading { padding: 60px 0; display: grid; place-items: center; }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } .switch .tr, .switch .tr::after, details.sec > summary .ic { transition: none; } }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; z-index: 100; background: #000; display: grid; place-items: center; padding: 24px; }
.login form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 14px; }
.login .logo { width: 230px; margin: 0 auto 26px; display: block; }
.login .msg { color: var(--warn); font-size: 14px; text-align: center; }

/* =====================================================================
   Print view — A4 sheets on white, built for the customer.
   ===================================================================== */
#print-root { display: none; }
body.printing #app { display: none; }
body.printing #print-root { display: block; min-height: 100vh; background: #1b1b1b; }
.pbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 8px; padding: calc(var(--safe-t) + 10px) 12px 10px;
  background: #000; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.pbar .grow { flex: 1; }
.pbar .ttl { font-weight: 500; font-size: 14.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbar .opts { width: 100%; display: flex; gap: 14px; align-items: center; padding-top: 4px; }
@media (min-width: 700px) { .pbar .opts { width: auto; padding: 0 8px; } }
@media (max-width: 560px) { .pbar .ttl { visibility: hidden; } }
.sheets { padding: 18px 0 40px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.sheet-fit { overflow: hidden; }
.sheet-fit > .a4 { transform-origin: top left; }

.a4 {
  width: 210mm; height: 297mm; padding: 13mm 12mm 12mm; background: #fff; color: #161616; position: relative; overflow: hidden;
  font-family: 'Poppins', sans-serif; font-size: 9pt; line-height: 1.45; box-shadow: 0 6px 30px rgba(0,0,0,.5);
  display: flex; flex-direction: column;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.a4 .d-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10mm; padding-bottom: 5mm; border-bottom: 0.4mm solid var(--gold); }
.a4 .d-logo { width: 52mm; height: auto; display: block; }
.a4 .d-title { text-align: right; }
.a4 .d-title .dt { font-size: 17pt; font-weight: 300; letter-spacing: 0.22em; text-transform: uppercase; color: #161616; line-height: 1.1; }
.a4 .d-title .meta { margin-top: 3mm; display: grid; grid-template-columns: auto auto; gap: 0.6mm 5mm; justify-content: end; font-size: 8.5pt; }
.a4 .d-title .meta .k { color: #8a8a8a; text-align: right; }
.a4 .d-title .meta .v { font-weight: 500; text-align: right; }
.a4 .d-cust { display: flex; justify-content: space-between; align-items: flex-end; gap: 8mm; padding: 4mm 0 3mm; }
.a4 .d-cust .k { font-size: 7.5pt; color: #8a8a8a; text-transform: uppercase; letter-spacing: .14em; }
.a4 .d-cust .n { font-size: 11pt; font-weight: 500; }
.a4 .d-cust .b { color: #555; }
.a4 .d-cont { display: flex; justify-content: space-between; align-items: center; padding-bottom: 3mm; border-bottom: 0.4mm solid var(--gold); margin-bottom: 1mm; }
.a4 .d-cont img { width: 30mm; }
.a4 .d-cont .r { font-size: 8.5pt; color: #8a8a8a; }
.a4 table.dt { width: 100%; border-collapse: collapse; table-layout: fixed; }
.a4 table.dt th {
  font-size: 6.8pt; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: #161616; text-align: left; white-space: nowrap;
  padding: 2.4mm 1.6mm 2mm; border-bottom: 0.5mm solid #161616;
}
.a4 table.dt th.r, .a4 table.dt td.r { text-align: right; }
.a4 table.dt td { padding: 2.8mm 1.6mm; border-bottom: 0.25mm solid #e6ddd0; vertical-align: top; font-variant-numeric: tabular-nums; }
.a4 table.dt td.r { white-space: nowrap; }
.a4 table.dt td.ph { padding: 2.2mm 1.6mm 2.2mm 0; }
.a4 table.dt td.opts { padding: 0; }
.a4 table.opt { width: 100%; border-collapse: collapse; table-layout: fixed; }
.a4 table.opt td { padding: 2.8mm 1.6mm; border-bottom: 0.25mm solid #f0e9df; vertical-align: top; font-variant-numeric: tabular-nums; }
.a4 table.opt tr:last-child td { border-bottom: 0; }
.a4 table.sum-t td { padding: 2.2mm 1.2mm; font-size: 8.4pt; }
.a4 table.sum-t th { padding-left: 1.2mm; padding-right: 1.2mm; }
.a4 table.sum-t td.ph { padding: 1.8mm 1.2mm 1.8mm 0; }
.a4 table.sum-t { --ph-max: 26mm; }
.a4 .pimg { display: block; max-width: 100%; max-height: var(--ph-max, 52mm); width: auto; height: auto; margin: 0; border-radius: 1mm; }
.a4 .pimg-none { width: 100%; height: 18mm; background: #f3efe9; border-radius: 1mm; }
.a4 .ds { font-weight: 500; font-size: 9.5pt; }
.a4 .ref { color: #8a8a8a; font-size: 8pt; margin-top: 0.6mm; }
.a4 .ml { overflow-wrap: anywhere; }
.a4 .pr { font-weight: 500; white-space: nowrap; }
.a4 .d-end { padding-top: 5mm; }
.a4 .tot { margin-left: auto; width: 82mm; }
.a4 .tot + .tot { margin-top: 5mm; }
.a4 .tot .l { display: flex; justify-content: space-between; padding: 1.2mm 0; font-size: 9.5pt; font-variant-numeric: tabular-nums; }
.a4 .tot .l .k { color: #6a6a6a; }
.a4 .tot .l.big { border-top: 0.4mm solid var(--gold); margin-top: 1.5mm; padding-top: 2.5mm; font-size: 12.5pt; font-weight: 600; }
.a4 .tot .l.bal { font-weight: 600; }
.a4 .tot .cur { color: #8a8a8a; font-size: 8pt; text-align: right; }
.a4 .note { margin-top: 6mm; font-size: 8.5pt; color: #444; white-space: pre-wrap; }
.a4 .note .k { font-size: 7.5pt; color: #8a8a8a; text-transform: uppercase; letter-spacing: .14em; display: block; margin-bottom: 1mm; }
.a4 .d-foot { margin-top: auto; padding-top: 4mm; display: flex; justify-content: space-between; align-items: flex-end; gap: 6mm; font-size: 7.5pt; color: #8a8a8a; }
.a4 .d-foot .fn { white-space: pre-wrap; max-width: 150mm; }
.a4 .stamp { display: inline-block; border: 0.3mm solid #161616; padding: 0.2mm 1.6mm; border-radius: 0.6mm; font-size: 7pt; font-weight: 600; letter-spacing: .08em; }
.a4 .stamp.paid { border-color: #2f7d55; color: #2f7d55; }
.a4 .stamp.part { border-color: #a8742f; color: #a8742f; }
.a4 .grp { font-size: 8pt; color: #8a8a8a; margin: 3mm 0 0; }

@page { size: A4 portrait; margin: 0; }
@media print {
  html, body { background: #fff !important; }
  body.printing #print-root { background: #fff; }
  .pbar, .toasts, .scrim, .viewer { display: none !important; }
  .sheets { padding: 0; gap: 0; display: block; }
  .sheet-fit { width: auto !important; height: auto !important; overflow: visible; }
  .sheet-fit > .a4 { transform: none !important; }
  .a4 { box-shadow: none; margin: 0; height: 296.5mm; break-after: page; page-break-after: always; }
  .sheet-fit:last-child .a4 { break-after: auto; page-break-after: auto; }
}

/* ---------- rupees & exchange ---------- */
.kpis.k5 > :last-child { grid-column: 1 / -1; }
@media (min-width: 760px) {
  .kpis.k5 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
  .kpis.k5 > :last-child { grid-column: auto; }
}
.kpi .v .profit, .kpi .v .loss, .kpi .v .warn { font-weight: inherit; }
.total-strip.inv-sum { margin: 0 0 14px; }
.pay-acts { display: flex; gap: 2px; flex: none; }
.pay-line .hint .profit, .pay-line .hint .loss { font-weight: 500; }
.rc-note.warn { color: var(--warn); }
.nw { white-space: nowrap; }
.row .t1 > span:first-child:not(.nm) { white-space: nowrap; flex: none; }
/* price · paid · balance: price gets its own row on a phone so amounts never break mid-number */
.total-strip.t3 .hero { grid-column: 1 / -1; }
@media (min-width: 560px) { .total-strip.t3 { grid-template-columns: repeat(3, 1fr); } .total-strip.t3 .hero { grid-column: auto; } }
.fx-total { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 2px 4px; border-top: 1px solid var(--gold); margin-top: 2px; font-size: 14px; }
.fx-total .v { font-size: 18px; font-variant-numeric: tabular-nums; }
