@font-face {
  font-family: "Playfair Display";
  src: url("/assets/fonts/PlayfairDisplay-Regular.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Playfair Display";
  src: url("/assets/fonts/PlayfairDisplay-Medium.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter Tight";
  src: url("/assets/fonts/InterTight-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter Tight";
  src: url("/assets/fonts/InterTight-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("/assets/fonts/CormorantGaramond-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("/assets/fonts/CormorantGaramond-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --porcelain: #F2F0EB;
  --midnight: #14161C;
  --platinum: #B4A899;
  --paper: #F7F5F1;
  --muted: #8A8580;
  --line: rgba(20, 22, 28, 0.10);
  --alert: #7A3E3E;
  --shadow: 0 10px 30px rgba(20, 22, 28, 0.06);
  --display: "Playfair Display", "Times New Roman", serif;
  --ui: "Inter Tight", -apple-system, BlinkMacSystemFont, sans-serif;
  --report: "Cormorant Garamond", "Times New Roman", serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --tab-h: 58px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--porcelain); color: var(--midnight); }
html { height: 100%; }
body {
  font-family: var(--ui);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; max-width: 100%; }

#app { min-height: 100%; }
.screen {
  min-height: 100dvh;
  padding: calc(var(--safe-top) + 18px) 22px 32px;
}
.screen[hidden], [hidden] { display: none !important; }
.screen.has-tab { padding-bottom: calc(var(--tab-h) + var(--safe-bot) + 28px); }
body.has-chrome .screen { padding-top: calc(var(--safe-top) + 54px); }

/* iOS chrome for screenshots */
#phone-chrome {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: 48px; padding: 14px 26px 0;
  display: flex; align-items: center; justify-content: space-between;
  pointer-events: none; color: var(--midnight);
  font-family: var(--ui); font-weight: 500; font-size: 15px;
  letter-spacing: -0.01em;
}
#phone-chrome .chrome-icons { display: flex; align-items: center; gap: 6px; }
#phone-chrome i { display: block; background: var(--midnight); }
#phone-chrome .sig {
  width: 17px; height: 11px;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 17 11'><rect x='0' y='8' width='3' height='3' rx='0.4'/><rect x='4.5' y='5.5' width='3' height='5.5' rx='0.4'/><rect x='9' y='3' width='3' height='8' rx='0.4'/><rect x='13.5' y='0' width='3' height='11' rx='0.4'/></svg>") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 17 11'><rect x='0' y='8' width='3' height='3' rx='0.4'/><rect x='4.5' y='5.5' width='3' height='5.5' rx='0.4'/><rect x='9' y='3' width='3' height='8' rx='0.4'/><rect x='13.5' y='0' width='3' height='11' rx='0.4'/></svg>") center / contain no-repeat;
}
#phone-chrome .wifi {
  width: 15px; height: 11px;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 11'><path fill='black' d='M7.5 11L1 4.2A10 10 0 0 1 14 4.2L7.5 11z'/></svg>") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 11'><path fill='black' d='M7.5 11L1 4.2A10 10 0 0 1 14 4.2L7.5 11z'/></svg>") center / contain no-repeat;
}
#phone-chrome .bat {
  width: 25px; height: 12px;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 25 12'><rect x='0.6' y='0.6' width='21.5' height='10.8' rx='2.4' fill='none' stroke='black' stroke-width='1.2'/><rect x='2.2' y='2.2' width='16.5' height='7.6' rx='1.2'/><rect x='22.6' y='3.6' width='1.6' height='4.8' rx='0.6'/></svg>") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 25 12'><rect x='0.6' y='0.6' width='21.5' height='10.8' rx='2.4' fill='none' stroke='black' stroke-width='1.2'/><rect x='2.2' y='2.2' width='16.5' height='7.6' rx='1.2'/><rect x='22.6' y='3.6' width='1.6' height='4.8' rx='0.6'/></svg>") center / contain no-repeat;
}

.eyebrow {
  margin: 0;
  font-family: var(--ui);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--platinum);
}
h1 {
  margin: 4px 0 0;
  font-family: var(--display);
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.page-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.page-head.compact { margin-bottom: 18px; }
.page-head .text-btn { margin-left: auto; }
.head-mark { width: 44px; height: 44px; flex: 0 0 auto; }

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.kpi {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 14px 14px 12px;
  min-height: 84px;
}
.kpi .k { color: var(--muted); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500; }
.kpi .v {
  margin-top: 8px;
  font-family: var(--display);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
}
.kpi .u { margin-top: 7px; color: var(--muted); font-size: 11px; letter-spacing: 0.04em; }
.kpi.wide { grid-column: 1 / -1; }

.block { margin-top: 20px; }
.block .eyebrow { margin-bottom: 10px; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 16px;
}
.card.quiet p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

.stock-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  background: var(--paper);
}
.stock-split div { padding: 14px 16px 16px; }
.stock-split > div + div { border-left: 1px solid var(--line); }
.stock-split .loc { color: var(--muted); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500; }
.stock-split .num { margin-top: 8px; font-family: var(--display); font-size: 28px; letter-spacing: -0.03em; }
.stock-split .u { margin-top: 6px; color: var(--muted); font-size: 11px; }

.row-list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row .name { font-family: var(--report); font-size: 18px; }
.row .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.row .amt { font-weight: 500; font-size: 14px; letter-spacing: -0.02em; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0 4px; }

/* Lock */
.screen-lock {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: calc(var(--safe-top) + 64px);
}
body.has-chrome .screen-lock { padding-top: calc(var(--safe-top) + 88px); }
.lock-brand { margin-bottom: 36px; }
.lock-mark { width: 92px; height: 92px; margin: 0 auto 22px; }
.lock-brand h1 { font-size: 30px; }
.lock-brand .eyebrow { margin-top: 8px; }

.pin-dots {
  display: flex; gap: 14px; justify-content: center; margin-bottom: 14px;
}
.pin-dots span {
  width: 8px; height: 8px; border-radius: 50%;
  border: 1px solid var(--midnight);
}
.pin-dots span.on { background: var(--midnight); }
.pin-error { color: var(--alert); font-size: 13px; margin: 0 0 10px; min-height: 18px; }

.keypad {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, 74px);
  gap: 12px 22px;
  justify-content: center;
}
.keypad button {
  width: 74px; height: 74px; border-radius: 50%;
  font-family: var(--display);
  font-size: 26px;
  border: 1px solid var(--line);
  background: var(--paper);
}
.keypad button:active { background: var(--midnight); color: var(--porcelain); }
.keypad button.ghost { border-color: transparent; background: transparent; }
.keypad button.key-del { font-size: 20px; font-family: var(--ui); border-color: transparent; background: transparent; }

/* Entry */
.stepper {
  display: flex; gap: 6px; margin: -6px 0 20px;
}
.stepper span {
  flex: 1; height: 1px; background: var(--line);
}
.stepper span.on { background: var(--midnight); }

.type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.type-tile {
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 18px 14px 16px;
  text-align: left;
  min-height: 72px;
}
.type-tile strong {
  display: block;
  font-family: var(--display);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.type-tile em {
  display: block; margin-top: 6px;
  font-style: normal; color: var(--muted); font-size: 11px; letter-spacing: 0.04em;
}
.type-tile:active, .type-tile.selected {
  border-color: var(--midnight);
  background: var(--midnight);
  color: var(--porcelain);
}
.type-tile:active em, .type-tile.selected em { color: var(--platinum); }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 8px;
}
.picker, .field input[type="text"], .field input[type="number"], .field input[type="date"], .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 14px 14px;
  font-size: 16px;
  text-align: left;
  appearance: none;
  border-radius: 0;
}
.picker .ph { color: var(--muted); }
.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  background: var(--paper);
}
.seg button {
  padding: 12px 0;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--muted);
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { color: var(--midnight); background: #EBE7E0; }

.qty-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.primary-btn, .ghost-btn {
  display: block; width: 100%;
  padding: 16px 18px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 500;
  margin-top: 10px;
}
.primary-btn { background: var(--midnight); color: var(--porcelain); }
.primary-btn:active { opacity: 0.88; }
.ghost-btn { border: 1px solid var(--line); background: transparent; }
.text-btn {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--muted);
  padding: 8px 0;
}
.review dl { margin: 0 0 20px; }
.review dt {
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); font-weight: 500; margin-top: 12px;
}
.review dt:first-child { margin-top: 0; }
.review dd { margin: 4px 0 0; font-family: var(--report); font-size: 20px; }

/* Voice */
.voice-stage {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 20px 8px 10px;
}
.voice-copy { color: var(--muted); max-width: 280px; line-height: 1.55; margin: 0 0 36px; }
.rec-btn {
  width: 112px; height: 112px; border-radius: 50%;
  position: relative;
  border: 1px solid var(--platinum);
}
.rec-ring {
  position: absolute; inset: 8px; border-radius: 50%;
  border: 1px solid var(--line);
}
.rec-core {
  position: absolute; inset: 36px; border-radius: 50%;
  background: var(--midnight);
  transition: border-radius 160ms ease, inset 160ms ease, background 160ms ease;
}
.rec-btn.live .rec-core {
  inset: 38px;
  border-radius: 4px;
  background: var(--alert);
}
.rec-btn.live { border-color: var(--alert); }
.voice-hint, .voice-timer { margin-top: 22px; letter-spacing: 0.12em; text-transform: uppercase; font-size: 11px; font-weight: 500; color: var(--muted); }
.voice-timer { font-family: var(--display); font-size: 28px; letter-spacing: 0; text-transform: none; color: var(--midnight); font-weight: 500; }
.voice-stage .primary-btn, .voice-stage .text-btn { width: min(260px, 100%); margin-top: 18px; }
.voice-ok .voice-copy { color: var(--midnight); font-family: var(--display); font-size: 26px; }
.voice-ok .transcript,
.voice-ok .transcript-edit,
.voice-ok .voice-fallback,
.voice-ok .lang-seg { display: none; }

.lang-seg { flex: 0 0 auto; width: auto; margin-left: auto; grid-template-columns: 1fr 1fr; }
.lang-seg button { padding: 8px 12px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }

.refresh-label {
  margin-left: auto;
  align-self: flex-start;
  margin-top: 6px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--platinum);
  font-weight: 500;
}
body.refreshing .page-head { position: relative; }
body.refreshing .page-head::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -10px; height: 1px;
  background: var(--platinum);
  opacity: 0.45;
  animation: refresh-pulse 1.4s ease-in-out infinite;
}
@keyframes refresh-pulse { 0%, 100% { opacity: 0.2; } 50% { opacity: 0.7; } }

.voice-fallback {
  margin-top: 22px;
  max-width: 280px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.transcript {
  width: 100%;
  text-align: left;
  min-height: 96px;
  margin-top: 28px;
  padding: 16px 16px 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-family: var(--report);
  font-size: 20px;
  line-height: 1.45;
  color: var(--midnight);
}
.transcript-interim { color: var(--muted); }
.transcript-edit {
  display: block;
  width: 100%;
  text-align: left;
  margin-top: 28px;
}
.transcript-edit textarea {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 14px 16px;
  min-height: 120px;
  resize: vertical;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--midnight);
  font-family: var(--report);
  font-size: 20px;
  line-height: 1.45;
  border-radius: 0;
}
.transcript-edit textarea:focus { outline: none; border-color: var(--platinum); }

/* Reports */
.report-list { border-top: 1px solid var(--line); }
.report-link {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; text-align: left;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.report-link strong { display: block; font-family: var(--display); font-weight: 500; font-size: 22px; }
.report-link span { color: var(--muted); font-size: 12px; margin-top: 4px; display: block; }
.report-link .chev { color: var(--platinum); font-size: 18px; }

.report-period { color: var(--muted); margin: -8px 0 18px; font-size: 13px; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-weight: 500; font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
  padding: 0 0 8px; border-bottom: 1px solid var(--platinum);
}
.table th.r, .table td.r { text-align: right; }
.table td {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: baseline;
}
.table td.name { font-family: var(--report); font-size: 16px; }
.table .sub { color: var(--muted); font-size: 11px; }
.status-alert { color: var(--alert); }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tab-h) + var(--safe-bot));
  padding-bottom: var(--safe-bot);
  background: rgba(242, 240, 235, 0.94);
  backdrop-filter: saturate(1.2) blur(16px);
  -webkit-backdrop-filter: saturate(1.2) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.active { color: var(--midnight); }

/* Sheet */
.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(20, 22, 28, 0.35); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 82dvh;
  background: var(--porcelain);
  padding: 8px 22px calc(var(--safe-bot) + 18px);
  display: flex; flex-direction: column;
  animation: rise 280ms ease;
}
@keyframes rise { from { transform: translateY(16px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 36px; height: 3px; background: var(--line); margin: 6px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font-family: var(--display); font-weight: 500; font-size: 24px; }
#sheet-search {
  width: 100%; border: 1px solid var(--line); background: var(--paper);
  padding: 12px 14px; font-size: 16px; margin-bottom: 8px;
}
.sheet-list { overflow: auto; -webkit-overflow-scrolling: touch; }
.sheet-item {
  display: block; width: 100%; text-align: left;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--report);
  font-size: 20px;
}
.sheet-item small { display: block; font-family: var(--ui); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }

.toast {
  position: fixed; left: 22px; right: 22px; bottom: calc(var(--tab-h) + var(--safe-bot) + 16px);
  z-index: 60;
  background: var(--midnight); color: var(--porcelain);
  text-align: center;
  padding: 14px 16px;
  letter-spacing: 0.08em; text-transform: uppercase;
  font-size: 11px; font-weight: 500;
}

@media (min-width: 480px) {
  body { display: flex; justify-content: center; background: #e6e2da; }
  #app, .tabbar, #phone-chrome, .sheet, .toast {
    width: 390px; margin: 0 auto; left: auto; right: auto;
  }
  #app { min-height: 844px; background: var(--porcelain); box-shadow: var(--shadow); }
  .tabbar, #phone-chrome, .sheet { width: 390px; }
  .sheet { left: 50%; transform: translateX(-50%); }
}

body.locked #tabbar { display: none !important; }
