/* Lim Gems Stock — one stylesheet, mobile first.
   Design pass, owner feedback batch 2 (2026-10-28): "clean, easy to read, easy to edit, a modern luxury feel",
   no rounded corners anywhere. LGF navy and gold on warm ivory, hairline rules, Source Serif 4 throughout. */
:root {
  --ivory: #f7f4ee;      /* the page */
  --paper: #fffefb;      /* panels, tables, inputs */
  --cream: #fbf6ea;      /* hover, the opened row, highlights */
  --ink: #16191f;
  --ink-2: #474b54;
  --ink-3: #6f6b62;      /* muted text: warm grey, still 4.9:1 on ivory */
  --line: #e2dbcc;       /* hairlines */
  --line-strong: #cbc1ad;
  --row-line: #ece6da;
  --navy: #14213d;       /* LGF navy: top bar, primary buttons */
  --accent: #1f3461;     /* links */
  --gold: #b08d4a;       /* LGF gold: rules and marks only (too faint for small text) */
  --gold-ink: #85662a;   /* gold that is dark enough for text */
  --gold-soft: #dcc89c;
  --accent-ink: #fffefb;
  --ok: #1d6b47;
  --ok-bg: #eaf3ec;
  --warn: #855a0c;
  --warn-bg: #fbf1dc;
  --err: #962d22;
  --err-bg: #f9e9e5;
  --info: #284f82;
  --info-bg: #ebf0f7;
  --syn: #6b2f6f;
  --syn-bg: #f3e9f2;
  --radius: 0;           /* owner feedback batch 2: square corners everywhere */
  --font: "Source Serif 4", "Noto Sans Thai", Georgia, "Times New Roman", serif;  /* Thai: a modern sans (owner, batch 3) */
  --tint: var(--cream);
  --caps: 600 11.5px/1.3 var(--font);
}
* { box-sizing: border-box; border-radius: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ivory); color: var(--ink);
  font: 16px/1.55 var(--font);
  font-optical-sizing: auto;
  /* Figures sit on the line (a serif may default to old-style figures that dip below it). */
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; }
a.plain { color: inherit; }
h1 { font-size: 2rem; font-weight: 600; margin: .1rem 0 .9rem; line-height: 1.15; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 1.8rem 0 .7rem; letter-spacing: -.005em; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
small, .muted { color: var(--ink-3); }
.lead { font-size: 1.02rem; max-width: 68ch; margin: -.3rem 0 1.2rem; }
.num, td.num, th.num { font-variant-numeric: lining-nums tabular-nums; text-align: right; white-space: nowrap; }
.center, td.center, th.center { text-align: center; }
code, .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.env-banner { background: var(--syn); color: #fff; text-align: center; font: var(--caps); letter-spacing: .14em;
  text-transform: uppercase; padding: 4px 8px; }

/* ---------------------------------------------------------------- top bar and menu */
.topbar { display: flex; align-items: center; gap: 18px; padding: 12px 24px; background: var(--navy); color: var(--paper);
  flex-wrap: wrap; border-bottom: 1px solid var(--gold); }
.brand { color: var(--gold-soft); font-weight: 600; font-size: 1rem; white-space: nowrap; letter-spacing: .26em;
  text-transform: uppercase; }
.brand span { color: var(--paper); font-weight: 400; letter-spacing: .12em; opacity: .7; margin-left: .35em; }
.brand:hover { text-decoration: none; }
.topsearch { flex: 1 1 220px; max-width: 520px; }
.topbar .topsearch input { width: 100%; padding: 8px 12px; border: 1px solid rgba(220, 200, 156, .35); font-size: 15px;
  background: rgba(255, 254, 251, .07); color: var(--paper); min-height: 38px; }
.topbar .topsearch input::placeholder { color: rgba(255, 254, 251, .55); }
.topbar .topsearch input:focus { outline: none; border-color: var(--gold-soft); background: rgba(255, 254, 251, .12); box-shadow: none; }
.who { display: flex; gap: 12px; align-items: center; font-size: 13.5px; white-space: nowrap; margin-left: auto; }
.who form { display: inline; }
.linklike { background: none; border: 0; color: #d6dcea; cursor: pointer; font: inherit; padding: 0; }
.linklike:hover { color: var(--gold-soft); }
.role { padding: 1px 7px; font: var(--caps); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; }
.role-owner { background: var(--gold-soft); color: var(--navy); }
.role-staff { background: rgba(255, 254, 251, .16); color: var(--paper); }

.mainnav { display: flex; gap: 4px; background: var(--paper); border-bottom: 1px solid var(--line); padding: 0 18px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; }
.mainnav a { padding: 13px 12px 11px; color: var(--ink-2); white-space: nowrap; border-bottom: 2px solid transparent;
  font: var(--caps); font-size: 12px; letter-spacing: .13em; text-transform: uppercase; }
.mainnav a.on { color: var(--ink); border-bottom-color: var(--gold); }
.mainnav a:hover { text-decoration: none; color: var(--ink); border-bottom-color: var(--line-strong); }
.badge { background: var(--err); color: #fff; padding: 0 5px; font-size: 10.5px; letter-spacing: 0; margin-left: 2px; }

.container { max-width: 1400px; margin: 0 auto; padding: 26px 24px 40px; }  /* 13 Stock columns (batch 3) */

/* ---------------------------------------------------------------- page heads, panels, cards */
.page-head, .split-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 20px;
  flex-wrap: wrap; margin-bottom: 6px; }
.page-head h1, .split-head h1 { margin-bottom: .5rem; }
.page-head .actions, .split-head .actions { margin: 0 0 .6rem; }
.back { display: inline-block; margin-bottom: 8px; font: var(--caps); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.back:hover { color: var(--ink); }

.card, .panel, .form-panel .form-section, .tile, .purchase {
  background: var(--paper); border: 1px solid var(--line); }
.card { padding: 18px 20px; margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 18px; }
.tile { padding: 16px 18px; color: inherit; display: block; }
a.tile:hover { text-decoration: none; border-color: var(--gold); }
.tile .v { font-size: 1.7rem; font-weight: 600; font-variant-numeric: lining-nums tabular-nums; line-height: 1.2; }
.tile .k { color: var(--ink-3); font: var(--caps); letter-spacing: .1em; text-transform: uppercase; margin-top: 4px; }
.tile.warn { border-color: #e6c98a; background: var(--warn-bg); }

.panel { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.panel h2, .form-section h2 { font: var(--caps); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); margin: 0; }
.panel h2::after, .form-section h2::after { content: ""; display: block; width: 28px; height: 1px; background: var(--gold);
  margin-top: 9px; }
.panel.section { margin: 18px 0; }
.panel .figure { margin: 0; color: var(--ink-2); }
.panel .figure .big { color: var(--ink); margin-right: 4px; }
.panel dl.facts { font-size: 15px; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 8px; }
.summary-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)); margin-bottom: 26px; }
.summary-grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* ---------------------------------------------------------------- messages and tags */
.alert { padding: 11px 14px; margin-bottom: 14px; border: 1px solid; border-left-width: 3px; background: var(--paper); }
.alert p { margin: 0; }
.alert-success { background: var(--ok-bg); border-color: #b9d8c2; border-left-color: var(--ok); color: var(--ok); }
.alert-error { background: var(--err-bg); border-color: #ebc3bb; border-left-color: var(--err); color: var(--err); }
.alert-warning { background: var(--warn-bg); border-color: #ecd49d; border-left-color: var(--warn); color: var(--warn); }
.alert-info { background: var(--info-bg); border-color: #c5d3e8; border-left-color: var(--info); color: var(--info); }

.chip { display: inline-block; padding: 1px 8px; font-size: 11.5px; font-weight: 600; letter-spacing: .04em;
  margin: 0 4px 4px 0; white-space: nowrap; border: 1px solid transparent; vertical-align: middle; }
.chip-ok { background: var(--ok-bg); color: var(--ok); border-color: #cfe3d4; }
.chip-warn { background: var(--warn-bg); color: var(--warn); border-color: #efdcb1; }
.chip-info { background: var(--info-bg); color: var(--info); border-color: #d3deee; }
.chip-muted { background: #f1ede5; color: var(--ink-2); border-color: var(--line); }
.chip-syn { background: var(--syn-bg); color: var(--syn); }
.chip-err { background: var(--err-bg); color: var(--err); }
.chip-gold { background: #f7f0de; color: var(--gold-ink); border-color: var(--gold-soft); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); background: var(--paper); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--row-line); text-align: left; vertical-align: top; }
th { font: var(--caps); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); background: var(--paper);
  white-space: nowrap; border-bottom: 1px solid var(--line-strong); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--cream); }
tr.dim td { color: var(--ink-3); }
tr.reversed td { text-decoration: line-through; text-decoration-color: #c9c2b3; }
tr.link-row { cursor: pointer; }
td.row-actions { white-space: nowrap; text-align: right; }

dl.facts { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); gap: 7px 18px; margin: 0; }
dl.facts dt { color: var(--ink-3); overflow-wrap: anywhere; max-width: 24ch; }
dl.facts dd { margin: 0; font-weight: 500; }
dl.facts.totals dd { text-align: right; }
.big { font-size: 1.65rem; font-weight: 600; font-variant-numeric: lining-nums tabular-nums; line-height: 1.2; }

/* ---------------------------------------------------------------- forms */
.form-panel { display: grid; gap: 16px; }
.form-panel .form-section { padding: 18px 20px 20px; }
.form-panel .form-section > .help { margin: 10px 0 0; }
.form-section h2 .step { display: inline-block; min-width: 1.6em; padding: 0 5px; margin-right: 8px; border: 1px solid var(--gold);
  color: var(--gold-ink); text-align: center; letter-spacing: 0; }
form.stack .fields, .form-panel .fields { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.form-section h2 + .fields, .form-section h2 + .help, .form-section .help + .fields, .form-section h2 + table,
.form-section .help + table { margin-top: 16px; }
.fields + .fields { margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide, .fields > .wide { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: 13.5px; color: var(--ink-2); }
.field.check label { font-weight: 500; display: flex; gap: 8px; align-items: center; color: var(--ink); }
.req { color: var(--err); }
.help { font-size: 12.5px; color: var(--ink-3); }
.owner-note { color: var(--gold-ink); }
.error { color: var(--err); font-size: 12.5px; display: block; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--err); }
input[type=text], input[type=search], input[type=number], input[type=date], input[type=datetime-local],
input[type=password], input[type=email], select, textarea, input:not([type]) {
  font: inherit; font-size: 15.5px; padding: 9px 11px; border: 1px solid #d3cbba; background: var(--paper); width: 100%;
  min-height: 42px; color: var(--ink);
}
select { appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
/* A pick-or-type field looks like a dropdown: it opens a list, and a new name can be typed. */
input[data-pick] { padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
input[data-pick]::-webkit-calendar-picker-indicator { display: none !important; }
input.num { text-align: right; font-variant-numeric: lining-nums tabular-nums; }
input::placeholder, textarea::placeholder { color: #a39d90; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(176, 141, 74, .28); }
input[type=checkbox], input[type=radio] { accent-color: var(--navy); width: 17px; height: 17px; }
.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 18px;
  border: 1px solid var(--navy); background: var(--navy); color: var(--accent-ink); font: inherit; font-size: 15px;
  font-weight: 600; letter-spacing: .02em; cursor: pointer; min-height: 42px; text-decoration: none; white-space: nowrap; }
.btn:hover { text-decoration: none; background: var(--accent); border-color: var(--accent); }
.btn:focus-visible, summary:focus-visible, a:focus-visible, tr:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn.secondary { background: transparent; color: var(--navy); border-color: var(--line-strong); }
.btn.secondary:hover { border-color: var(--navy); background: var(--paper); }
.btn.danger { background: var(--err); border-color: var(--err); }
.btn.small { padding: 5px 12px; min-height: 32px; font-size: 13.5px; }
.btn[disabled] { opacity: .55; cursor: wait; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.form-panel > .form-actions { margin-top: 2px; }

/* Fold-outs: "More details", charges, invoice wording */
details.more-details { background: var(--paper); border: 1px solid var(--line); }
details.more-details > summary { cursor: pointer; padding: 13px 20px; list-style: none; font-weight: 600; display: flex;
  gap: 10px; align-items: baseline; flex-wrap: wrap; }
details.more-details > summary::-webkit-details-marker { display: none; }
details.more-details > summary::before { content: "+"; color: var(--gold-ink); font-weight: 400; width: 12px; }
details.more-details[open] > summary::before { content: "−"; }
details.more-details > summary .muted { font-weight: 400; font-size: 13.5px; }
details.more-details > :not(summary) { margin: 0 20px 18px; }
details.more-details > table { width: calc(100% - 40px); }
details.danger-zone { margin-top: 26px; }
details.danger-zone > summary { color: var(--err); }
.into-choice { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 14px; }
.radio-card { display: inline-flex; gap: 9px; align-items: center; padding: 10px 16px; border: 1px solid var(--line-strong);
  cursor: pointer; background: var(--paper); font-weight: 500; }
.radio-card:has(input:checked) { border-color: var(--navy); box-shadow: inset 0 -2px 0 var(--gold); }
.code-hint { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 3px; min-height: 0; }
.code-hint.warn { color: var(--warn); }
.code-hint:empty { display: none; }

.rows { width: 100%; }
.rows td { padding: 5px 8px 5px 0; border: 0; vertical-align: top; }
.rows th { background: none; padding: 4px 8px 6px 0; border-bottom: 0; }
.rows tbody tr:hover { background: none; }
.rows input, .rows select { min-width: 90px; }
.rows td.rownum { color: var(--gold-ink); font-weight: 600; padding-top: 14px; width: 2em; }
.sale-rows td.line-total { padding-top: 14px; font-weight: 600; min-width: 7em; }
details.row-more > summary { cursor: pointer; color: var(--accent); font-size: 13.5px; padding-top: 11px; white-space: nowrap; }
details.row-more[open] { min-width: 220px; }
details.row-more .field { margin-top: 8px; }
.sale-total { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; justify-content: flex-end;
  border-top: 1px solid var(--line-strong); padding-top: 12px; font-size: 1.05rem; }
.sale-total b { font-size: 1.5rem; font-variant-numeric: lining-nums tabular-nums; }
.sale-total small { flex-basis: 100%; text-align: right; }

/* Suggestions under a pick-or-type field or an item-code field (app.js) */
.suggest { position: absolute; z-index: 50; margin: 0; padding: 4px 0; list-style: none; background: var(--paper);
  border: 1px solid var(--line-strong); box-shadow: 0 14px 34px rgba(20, 33, 61, .14); max-height: 300px; overflow-y: auto;
  max-width: min(460px, calc(100vw - 20px)); }
.suggest li { padding: 8px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.suggest li small { font-size: 12.5px; color: var(--ink-3); }
.suggest li.on, .suggest li:hover { background: var(--cream); box-shadow: inset 2px 0 0 var(--gold); }
.suggest li.add { border-top: 1px solid var(--row-line); color: var(--gold-ink); font-weight: 600; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--row-line); display: grid; grid-template-columns: 9.5rem 1fr auto;
  gap: 4px 12px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--ink-3); font-size: 13px; }
.timeline .what b { font-weight: 600; }
.timeline .qty { text-align: right; font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.pos { color: var(--ok); } .neg { color: var(--err); }

.qr svg { width: 120px; height: 120px; }
.pager { display: flex; gap: 12px; align-items: center; margin: 14px 0; flex-wrap: wrap; }
.filters { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
.filters .field label { font-size: 12.5px; }

/* ---------------------------------------------------------------- sign-in pages (templates/accounts/_auth.html)
   Sui, 2026-10-29: "make sure the log in page looks like a worldclass startup". The LGF sunburst on navy, drawn in
   hairline gold rays that rise on load, a light passing over the mark; beside it one plain action on ivory. */
.auth-body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100svh; }
.auth { flex: 1; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(400px, 1fr); }
.auth-show { position: relative; overflow: hidden; isolation: isolate; display: grid; place-items: center;
  background: radial-gradient(120% 70% at 50% 100%, #233a66 0%, var(--navy) 55%, #0b1428 100%); color: var(--gold-soft); }
.auth-show::before { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: .09;
  mix-blend-mode: overlay; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.auth-show::after { content: ""; position: absolute; left: 50%; bottom: -18%; width: 70%; aspect-ratio: 1; z-index: 0;
  transform: translateX(-50%); background: radial-gradient(closest-side, rgba(220, 200, 156, .22), transparent);
  animation: auth-breathe 7s ease-in-out 1.8s infinite; }
.auth-rays { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1;
  /* fade the rays around the mark so it stands clear of them */
  -webkit-mask: radial-gradient(circle at 50% 50%, transparent 0 16%, #000 34%);
  mask: radial-gradient(circle at 50% 50%, transparent 0 16%, #000 34%); }
.auth-rays line { stroke: var(--gold); stroke-width: 1; vector-effect: non-scaling-stroke; opacity: .34;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: auth-ray 1.6s cubic-bezier(.2, .7, .1, 1) calc(.15s + var(--i) * 55ms) forwards; }
.auth-rays line:nth-child(even) { opacity: .2; }
.auth-mark { position: relative; z-index: 3; width: min(300px, 46%); opacity: 0;
  animation: auth-rise 1.1s cubic-bezier(.2, .7, .1, 1) .55s forwards; }
.auth-mark img { display: block; width: 100%; height: auto; filter: drop-shadow(0 10px 30px rgba(0, 0, 0, .35)); }
/* The glint: a band of light crossing the mark only (masked by the logo itself), like a stone turned in the hand. */
.auth-mark::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  -webkit-mask: url("../brand/lgf-gold.png") center / contain no-repeat; mask: url("../brand/lgf-gold.png") center / contain no-repeat;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 249, 230, .85) 50%, transparent 62%) no-repeat;
  background-size: 260% 100%; background-position: 160% 0; animation: auth-glint 7.5s ease-in-out 2.2s infinite; }
.auth-tagline { position: absolute; z-index: 3; left: 0; right: 0; bottom: clamp(22px, 5vh, 48px); margin: 0;
  text-align: center; font-style: italic; font-size: 1.05rem; letter-spacing: .01em; color: rgba(220, 200, 156, .78);
  opacity: 0; animation: auth-rise 1s ease-out 1.3s forwards; }

.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(32px, 7vw, 88px);
  background: var(--paper); border-left: 1px solid var(--gold); position: relative; }
.auth-panel::before { content: ""; position: absolute; inset: 14px; border: 1px solid var(--row-line); pointer-events: none; }
.auth-form { width: 100%; max-width: 400px; margin: auto 0; position: relative; }
.auth-form > * { opacity: 0; animation: auth-rise .8s cubic-bezier(.2, .7, .1, 1) forwards; }
.auth-form > :nth-child(1) { animation-delay: .35s; } .auth-form > :nth-child(2) { animation-delay: .45s; }
.auth-form > :nth-child(3) { animation-delay: .55s; } .auth-form > :nth-child(4) { animation-delay: .65s; }
.auth-form > :nth-child(5) { animation-delay: .75s; } .auth-form > :nth-child(n+6) { animation-delay: .85s; }
.auth-eyebrow { font: var(--caps); letter-spacing: .3em; text-transform: uppercase; color: var(--gold-ink);
  margin: 0 0 18px; display: flex; align-items: center; gap: 12px; }
.auth-eyebrow::after { content: ""; flex: 0 0 44px; height: 1px; background: var(--gold); }
.auth-title { font-size: clamp(2.2rem, 3.4vw, 2.9rem); font-weight: 600; letter-spacing: -.022em; line-height: 1.04;
  margin: 0 0 14px; color: var(--ink); }
.auth-lead { color: var(--ink-2); font-size: 1.06rem; margin: 0 0 30px; max-width: 34ch; }

.auth-google, .auth-submit { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%;
  min-height: 54px; padding: 12px 20px; cursor: pointer; font: 600 16px/1.2 var(--font); letter-spacing: .01em;
  transition: transform .18s ease, box-shadow .25s ease, border-color .2s ease, background-color .2s ease; }
.auth-google { background: #fff; color: var(--ink); border: 1px solid var(--line-strong);
  box-shadow: 0 1px 0 rgba(20, 33, 61, .04), 0 1px 2px rgba(20, 33, 61, .06); }
.auth-google:hover { text-decoration: none; border-color: var(--navy); transform: translateY(-1px);
  box-shadow: 0 12px 28px -14px rgba(20, 33, 61, .45), inset 0 -2px 0 var(--gold); }
.auth-submit { background: var(--navy); color: var(--paper); border: 1px solid var(--navy); margin-top: 22px;
  box-shadow: inset 0 -2px 0 var(--gold); }
.auth-submit:hover { background: var(--accent); transform: translateY(-1px); box-shadow: 0 12px 28px -14px rgba(20, 33, 61, .7), inset 0 -2px 0 var(--gold); }
.auth-google:active, .auth-submit:active { transform: translateY(0); box-shadow: none; }
.auth-google:focus-visible, .auth-submit:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.auth-fields .field + .field { margin-top: 14px; }
.auth-fields .field label { font: var(--caps); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }
.auth-fields input { min-height: 50px; font-size: 16px; padding: 12px 14px; background: #fff; }
.auth-note { display: flex; gap: 10px; align-items: flex-start; margin: 26px 0 0; padding-top: 18px;
  border-top: 1px solid var(--row-line); color: var(--ink-3); font-size: .92rem; line-height: 1.5; }
.auth-note svg { flex: none; margin-top: 3px; color: var(--gold-ink); }
.auth-foot { display: flex; justify-content: space-between; gap: 8px 20px; flex-wrap: wrap; margin-top: 40px;
  font: var(--caps); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); position: relative; }

@keyframes auth-ray { to { stroke-dashoffset: 0; } }
@keyframes auth-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes auth-glint { 0%, 62% { background-position: 160% 0; } 100% { background-position: -60% 0; } }
@keyframes auth-breathe { 0%, 100% { opacity: .75; } 50% { opacity: 1; } }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-show { min-height: 36vh; min-height: 36svh; padding: 28px 0 54px; }
  .auth-mark { width: min(170px, 42vw); }
  .auth-tagline { font-size: .95rem; bottom: 18px; }
  .auth-panel { border-left: 0; border-top: 1px solid var(--gold); padding: 34px 24px 26px; justify-content: flex-start; }
  .auth-panel::before { inset: 8px; }
  .auth-form { margin: 0 auto; }
  .auth-foot { margin-top: 34px; justify-content: center; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-rays line { animation: none; stroke-dashoffset: 0; }
  .auth-mark, .auth-tagline, .auth-form > * { animation: none; opacity: 1; }
  .auth-mark::after, .auth-show::after { animation: none; }
  .auth-google, .auth-submit { transition: none; }
}

.sm-unit { display: none; }
details.more-filters > summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 6px 0 0; }
details.more-filters[open] > summary { margin-bottom: 12px; }
.search-card { background: var(--paper); border: 1px solid var(--line); padding: 16px 18px; margin-bottom: 12px; }
.search-row { display: flex; gap: 10px; align-items: end; }
.search-row .field { flex: 1; }
.search-row .field:last-child { flex: 0 0 auto; }
.search-row .field:last-child .btn { min-width: 120px; }
.search-row .field label { font: var(--caps); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }

/* ---------------------------------------------------------------- Stock list */
.list-summary { margin: 4px 2px 10px; color: var(--ink-2); font-variant-numeric: lining-nums; }
table.stock-table th { padding: 12px 6px 10px; letter-spacing: .06em; position: sticky; top: 0; z-index: 1; }
table.stock-table td { padding: 12px 6px; vertical-align: baseline; font-size: 15px; }  /* 13 columns fit 1,366 px (batch 3) */
table.stock-table td.code-cell { white-space: nowrap; font-weight: 600; }
table.stock-table td { white-space: nowrap; }  /* one line per item (owner, batch 3) */
.clip { display: inline-block; max-width: 8em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  vertical-align: bottom; }
.clip-s { max-width: 6.5em; }
.clip-l { max-width: 9em; }
table.stock-table td.code-cell a { color: var(--ink); }
table.stock-table td.code-cell a:hover { color: var(--accent); }
table.stock-table td.weight { font-weight: 600; }
table.stock-table .held { font-weight: 400; color: var(--info); font-size: 12.5px; }
table.stock-table td.location-cell { white-space: nowrap; }
tr.item-row { cursor: pointer; }
tr.item-row:hover td { background: var(--cream); }
tr.item-row:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
tr.item-row[aria-expanded="true"] td { background: var(--cream); border-bottom-color: transparent; }
tr.item-row[aria-expanded="true"] td.code-cell { box-shadow: inset 3px 0 0 var(--gold); }
.fair-tag { white-space: nowrap; color: var(--gold-ink); }
.cert-link { white-space: nowrap; }
.cert-link.more { display: none; }
/* Several certificates (owner, batch 3): the list opens under the words, the row grows only while it is open. */
details.cert-menu > summary { cursor: pointer; color: var(--accent); list-style: none; font-size: 14px; }
details.cert-menu > summary::-webkit-details-marker { display: none; }
details.cert-menu > summary::after { content: " ▾"; font-size: .8em; }
details.cert-menu[open] > summary::after { content: " ▴"; }
details.cert-menu ul { list-style: none; margin: 6px 0 0; padding: 6px 10px; border-left: 2px solid var(--gold); }
details.cert-menu li { margin: 2px 0; }
.op-code { font-family: "Noto Sans Thai", system-ui, sans-serif; }
.cert-icon { display: inline-block; width: 11px; height: 14px; border: 1px solid currentColor; margin-right: 6px; vertical-align: -1px;
  background: linear-gradient(currentColor, currentColor) 2px 4px / 5px 1px no-repeat,
              linear-gradient(currentColor, currentColor) 2px 7px / 5px 1px no-repeat; }

/* The opened row: a drawer of its own, so it does not read as part of the list (owner feedback batch 2). */
tr.activity-row > td { background: var(--cream); padding: 6px 18px 20px 22px; border-bottom: 1px solid var(--line-strong);
  box-shadow: inset 3px 0 0 var(--gold); cursor: default; animation: drawer-in .18s ease-out; }
@keyframes drawer-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.drawer-title { margin: 8px 0 10px; font-weight: 600; font-size: 15px; }
.drawer-title span { font: var(--caps); letter-spacing: .16em; text-transform: uppercase; color: var(--gold-ink); margin-right: 8px; }
tr.activity-row table.activity { background: var(--paper); border: 1px solid var(--line); }
.activity-foot { margin: 10px 2px 0; font-size: 14px; }
.activity-note { margin: 8px 2px 0; font-size: 12.5px; color: var(--ink-3); max-width: 70ch; }

/* The certificate viewer */
dialog.viewer { padding: 0; border: 1px solid var(--gold); background: var(--paper); width: min(1000px, 96vw);
  max-height: 94vh; color: var(--ink); }
dialog.viewer::backdrop { background: rgba(20, 33, 61, .72); }
.viewer-bar { display: flex; gap: 10px 14px; align-items: center; flex-wrap: wrap; padding: 12px 16px;
  border-bottom: 1px solid var(--line); }
.viewer-bar b { font-weight: 600; }
.viewer-count { font-size: 13.5px; flex: 1; }
.viewer-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.viewer-body { display: flex; justify-content: center; align-items: center; background: #f1ede4; min-height: 50vh; }
.viewer-body img { max-width: 100%; max-height: 78vh; display: block; }
.viewer-body iframe { width: 100%; height: 78vh; border: 0; background: #fff; }
.viewer-note { padding: 40px 20px; color: var(--ink-2); }
dialog.undo-dialog { width: min(460px, 94vw); }
.undo-slot form { display: grid; gap: 10px; padding: 16px 18px 18px; }
.undo-slot label { display: grid; gap: 5px; font-weight: 600; font-size: 13.5px; color: var(--ink-2); }
.undo-slot .form-actions { margin-top: 4px; }

/* ---------------------------------------------------------------- Activity and History tables (item page) */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.activity, table.history, table.compact-table { background: var(--paper); border: 1px solid var(--line); }
table.activity th, table.history th, table.compact-table th { padding: 10px 12px; }
table.activity td, table.history td, table.compact-table td { padding: 9px 12px; vertical-align: baseline; }
table.activity td.date, table.history td.date { white-space: nowrap; color: var(--ink-2); }
table.activity td.date abbr { text-decoration: none; color: var(--warn); font-weight: 700; margin-left: 2px; cursor: help; }
table.activity td.kind, table.history td.kind { white-space: nowrap; font-weight: 600; letter-spacing: .04em; font-size: 13.5px; }
table.activity td small { display: block; font-weight: 400; color: var(--ink-3); font-size: 12px; }
table.activity td.kind .src { letter-spacing: 0; }
table.activity td.acct { white-space: nowrap; }
/* Activity totals and filter (owner, batch 3). Headings may wrap so the totals fit a phone. */
.activity-totals { margin: 10px 0 14px; max-width: 760px; }
.activity-totals .totals-weight { margin: 0 0 6px; }
.activity-totals table.totals { background: var(--paper); border: 1px solid var(--line); table-layout: fixed; }
.activity-totals table.totals th { white-space: normal; }
.activity-totals table.totals td, .activity-totals table.totals th { padding: 8px 10px; overflow-wrap: anywhere; }
.activity-totals table.totals tbody th { font: inherit; letter-spacing: 0; text-transform: none; color: var(--ink-2); }
.activity-filter { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 4px 0 6px; }
.activity-filter label.check { display: inline-flex; gap: 5px; align-items: center; font-size: 14px; font-weight: 600;
  letter-spacing: .04em; }
table.activity td .neg, .activity-totals .neg { color: var(--err); }
.cert-card { border: 1px solid var(--line); background: var(--paper); padding: 14px 16px; margin: 0 0 12px; }
.cert-card h3 { margin: 0 0 8px; }
.files-head { margin-top: 18px; }
table.activity td.detail, table.history td.detail { color: var(--ink-2); font-size: 14px; min-width: 14rem; }
table.activity td.detail .who { display: inline; }
table.history td.who { white-space: nowrap; color: var(--ink-2); font-size: 14px; }
table.activity tr.book td { background: #fdfaf2; }
table.activity tr.reversed td:not(:last-child), table.history tr.reversed td { text-decoration: line-through;
  text-decoration-color: #c2baa9; color: var(--ink-3); }
table.activity tr.undo td { color: var(--ink-3); }
.kind-purchase, .kind-mix-in { color: var(--ok); }
.kind-sales { color: var(--accent); }
.kind-mix-out { color: #6b2f6f; }
.kind-lost { color: var(--err); }
.kind-correction { color: var(--warn); }
.carried { color: var(--ink-3); }
.kind-starting-balance, .kind-undone, .kind-moved, .kind-checked, .kind-reserved, .kind-weighed, .kind-edited,
.kind-file-added, .kind-file-removed, .kind-reservation-ended { color: var(--ink-3); }
table.activity.compact td, table.activity.compact th { padding: 7px 10px; font-size: 14px; }
.history-section { margin-top: 34px; }

/* ---------------------------------------------------------------- Item page */
.item-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap;
  padding-bottom: 4px; }
.item-code { font-size: 2.4rem; margin: 0; letter-spacing: -.01em; overflow-wrap: anywhere; }
.item-desc { margin: 4px 0 10px; color: var(--ink-2); font-size: 1.1rem; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin: 18px 0 20px; overflow-x: auto; }
.tabs a { padding: 10px 12px 9px; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap;
  font: var(--caps); font-size: 12px; letter-spacing: .13em; text-transform: uppercase; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--gold); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs .count { font-size: 11px; color: var(--ink-3); letter-spacing: 0; }
.hold-line { font-size: 14px; color: var(--info); }
form.inline { display: inline; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline;
  text-decoration-color: var(--gold-soft); text-underline-offset: 3px; }
.photo-panel img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--cream); display: block; }
.photo-empty { width: 100%; aspect-ratio: 4 / 3; border: 1px dashed var(--line-strong); background: var(--cream); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px 16px; flex-wrap: wrap; }
.section-head h2 { margin: 0 0 10px; font-size: 1.35rem; }
.section-head .toggle { font-size: 13.5px; }
.add-activity { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin: 14px 0 6px; }
.add-label { color: var(--ink-3); padding-top: 6px; font: var(--caps); letter-spacing: .14em; text-transform: uppercase; }
details.action-box > summary { list-style: none; }
details.action-box > summary::-webkit-details-marker { display: none; }
details.action-box[open] { flex-basis: 100%; width: 100%; min-width: 0; }
details.action-box[open] > summary { background: var(--navy); color: var(--paper); border-color: var(--navy); }
/* An open button stays navy on hover: .btn.secondary:hover would turn it white under white text (owner, batch 3). */
details.action-box[open] > summary:hover { background: var(--navy); color: var(--paper); border-color: var(--navy); }
.action-form { background: var(--paper); border: 1px solid var(--line); border-top: 2px solid var(--gold); padding: 16px 18px;
  margin-top: 8px; }
.action-form .fields { display: grid; gap: 12px 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.action-form .form-actions { margin-top: 14px; }
.panel details.action-box[open] { flex-basis: auto; width: 100%; }
.panel .action-form .fields { grid-template-columns: 1fr; }
details.undo-box > summary { cursor: pointer; color: var(--accent); font-size: 13.5px; list-style: none; }
details.undo-box > summary::-webkit-details-marker { display: none; }
details.undo-box form { display: grid; gap: 8px; min-width: 240px; margin-top: 6px; }
details.undo-box .form-actions { margin-top: 2px; }
.files-section .lead { margin-top: 0; }
.file-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); margin-bottom: 18px; }
.file-card { margin: 0; background: var(--paper); border: 1px solid var(--line); overflow: hidden; }
.file-card img, .file-card video { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #111; }
.file-card img { background: var(--cream); }
.file-doc { display: flex; flex-direction: column; align-items: center; justify-content: center; aspect-ratio: 4 / 3;
  background: var(--cream); font-weight: 700; color: var(--accent); letter-spacing: .1em; }
.file-card figcaption { padding: 9px 11px; display: grid; gap: 2px; font-size: 14px; }
.file-name { overflow-wrap: anywhere; }
.upload-form { background: var(--paper); border: 1px solid var(--line); padding: 16px 18px; max-width: 580px; display: grid; gap: 8px; }

/* ---------------------------------------------------------------- Client page */
.purchase { margin-bottom: 14px; }
.purchase.dim { opacity: .72; }
.purchase-head { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; padding: 12px 16px;
  border-bottom: 1px solid var(--line); }
.purchase-head .chip { margin: 0; }
.purchase-total { margin-left: auto; font-weight: 600; font-size: 1.05rem; }
.purchase table.compact-table { border: 0; }

/* ---------------------------------------------------------------- Owner questions and the feedback box */
.qa { display: grid; gap: 6px; padding: 12px 0; border-top: 1px solid var(--line); scroll-margin-top: 12px; }
.qa-section h2 + .qa, .qa-section p + .qa { border-top: 0; }
.qa label { font-weight: normal; }
.earlier-answers summary { cursor: pointer; color: var(--ink-3); font-size: 14px; }
.earlier-answers ul { margin: 6px 0 0; padding-left: 18px; }
.earlier-answers li { margin: 6px 0; }
.qa .qid { font-variant-numeric: tabular-nums; margin-right: 4px; color: var(--gold-ink); font-weight: 600; }
.qa textarea { width: 100%; min-height: 4.5em; }
.qa:target { outline: 2px solid var(--gold); outline-offset: 4px; }
.save-state.err { color: var(--err); }
.feedback-box { margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--line); }
.feedback-box summary { cursor: pointer; color: var(--ink-3); font-size: 14px; }
.feedback-box form { display: grid; gap: 6px; margin-top: 8px; max-width: 640px; }
.feedback-box textarea { width: 100%; }

@media (max-width: 640px) {
  /* Label above value: a long label ("TOTAL CIP HO CHI MINH CITY, VIETNAM") must not squeeze a total. */
  dl.facts { grid-template-columns: minmax(0, 1fr); gap: 0; }
  dl.facts dt { max-width: none; }
  dl.facts dd { margin-bottom: 9px; }
  dl.facts.totals dd { text-align: left; }
  .container { padding: 16px 12px 32px; }
  .topbar { padding: 10px 12px; gap: 10px; }
  .timeline li { grid-template-columns: 1fr auto; }
  .timeline .when { grid-column: 1 / -1; }
  h1 { font-size: 1.6rem; }
  .who { width: 100%; justify-content: flex-end; margin-left: 0; }
  /* Every page link stays visible on a phone instead of hiding off-screen. */
  .mainnav { flex-wrap: wrap; overflow-x: visible; padding: 0 6px; }
  .mainnav a { padding: 10px 9px 8px; letter-spacing: .1em; }
  .qr { display: none; }
  .card, .panel, .form-panel .form-section { padding: 14px 14px 16px; }
  details.more-details > summary { padding: 12px 14px; }
  details.more-details > :not(summary) { margin: 0 14px 14px; }
  details.more-details > table { width: calc(100% - 28px); }

  /* Tables marked .cards-sm become one compact card per row. */
  /* Child selectors only: a table nested inside a card (the opened activity) keeps its own layout. */
  table.cards-sm > thead { display: none; }
  table.cards-sm, table.cards-sm > tbody, table.cards-sm > tbody > tr, table.cards-sm > tbody > tr > td { display: block; width: 100%; }
  table.cards-sm > tbody > tr { padding: 12px 14px; border-bottom: 1px solid var(--row-line); }
  table.cards-sm > tbody > tr:last-child { border-bottom: 0; }
  table.cards-sm > tbody > tr > td { border: 0; padding: 2px 0; text-align: left; white-space: normal; }
  table.cards-sm > tbody > tr > td.num, table.cards-sm > tbody > tr > td.center, table.cards-sm > tbody > tr > td.row-actions { text-align: left; }
  table.cards-sm > tbody > tr > td[data-label]::before { content: attr(data-label) " "; color: var(--ink-3); font-size: 12px; }
  table.cards-sm > tbody > tr > td.hide-sm { display: none; }
  table.cards-sm > tbody > tr > td.inline-sm { display: inline-block; width: auto; margin-right: 14px; }
  table.cards-sm .sm-unit { display: inline; }

  /* Split / merge / sale rows: one labelled block per row. */
  table.rows thead { display: none; }
  table.rows, table.rows tbody, table.rows tr, table.rows td { display: block; width: 100%; }
  table.rows tr { padding: 12px 0; border-bottom: 1px solid var(--row-line); }
  table.rows td { padding: 3px 0; }
  table.rows td[data-label]::before { content: attr(data-label); display: block; font-size: 12.5px; font-weight: 600;
    color: var(--ink-2); margin-bottom: 2px; }
  table.rows td[data-label=""]::before { content: none; }
  table.rows td.rownum { padding-top: 0; }
  table.rows input, table.rows select { min-width: 0; }
  .sale-rows td.line-total { text-align: left; padding-top: 3px; }
  .search-row { flex-wrap: wrap; }
}
@media (max-width: 640px) {
  /* The activity log as one small block per line: date and activity, then the numbers, each labelled. */
  table.activity, table.activity tbody, table.activity tr, table.activity td,
  table.history, table.history tbody, table.history tr, table.history td { display: block; width: auto; }
  table.activity thead, table.history thead { display: none; }
  table.activity tr, table.history tr { padding: 9px 12px; border-bottom: 1px solid var(--row-line); }
  table.activity tr:last-child, table.history tr:last-child { border-bottom: 0; }
  table.activity td, table.history td { border: 0; padding: 1px 0; text-align: left; white-space: normal; min-width: 0; }
  table.activity td.date, table.activity td.kind, table.history td.date, table.history td.kind { display: inline-block; margin-right: 10px; }
  table.activity td.num, table.activity td.acct, table.history td.num, table.history td.who { display: inline-block; margin-right: 14px; text-align: left; }
  table.activity td.num:empty, table.activity td.acct:empty, table.history td.num:empty, table.history td.detail:empty { display: none; }
  table.activity td[data-label]::before, table.history td[data-label]::before { content: attr(data-label) " "; color: var(--ink-3); font-size: 11.5px; }
  table.activity td small { display: inline; margin-left: 4px; }
  table.activity td.detail, table.history td.detail { min-width: 0; }
  table.activity td.detail:empty { display: none; }
  .btn.small, details.action-box > summary.btn { min-height: 44px; padding: 8px 14px; }
  details.undo-box > summary { font-size: 15px; padding: 10px 0; }
  table.stock-table > tbody > tr > td { padding: 2px 0; border: 0; }
  table.stock-table tr.item-row { padding: 12px 14px; }
  table.stock-table td.code-cell { font-size: 1.1rem; }
  table.stock-table > tbody > tr > td.inline-sm { margin-right: 10px; }
  table.stock-table > tbody > tr > td.inline-sm:empty { display: none; }
  table.stock-table .held { display: inline; margin-left: 6px; }
  table.stock-table .fair-tag { display: inline; margin-left: 6px; }
  tr.activity-row > td { padding: 4px 10px 14px 14px; }
  .item-code { font-size: 1.8rem; }
  table.activity td.detail { min-width: 10rem; }
  .purchase-total { margin-left: 0; flex-basis: 100%; }
  .viewer-body iframe { height: 60vh; }
}
@media (prefers-reduced-motion: reduce) { tr.activity-row > td { animation: none; } }
@media print {
  .topbar, .mainnav, .env-banner, .actions, .form-actions, .no-print { display: none !important; }
  body { background: #fff; }
  .card, .table-wrap, .panel { border: 0; }
}
