/* Sổ Vàng — bản web dùng thử. Token chép từ ios/SoVang/Design/Theme.swift (khung 390 × 844 pt); cỡ chữ = Font.sv*.
   CSP: style-src 'self' ⇒ mọi kiểu nằm ở đây (không style viết thẳng trong HTML). Chỉ animate transform / opacity. */

:root {
  color-scheme: dark;
  /* màu */
  --bg: #050505;
  --card: #121212;
  --tile: #1b1b1b;
  --tile-end: #101010;
  --chip-bg: #141414;
  --chip-border: #2c2c2c;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-gold: rgba(232, 190, 100, 0.45);
  --divider: #2a2a2a;
  --gold100: #fbe7a8;
  --gold300: #f7d98a;
  --gold400: #e9c46a;
  --gold500: #e0ae45;
  --gold700: #b07f22;
  --gold900: #3a2d0f;
  --text: #f5f5f5;
  --text2: #bdbdbd;
  --text3: #8a8a8a;
  --hero-sub: #e8e1d0;
  --on-gold: #241804;
  --tab-idle: #d0d0d0;
  --success: #3fd46b;
  --success-bg: #1e6b34;
  --danger: #ff4d4f;
  --danger-bg: #7a1e1e;
  --info-bg: #1f4fb0;
  --badge: #ff3b30;
  --warn: #ffb547;
  /* gradient */
  --g-gold-button: linear-gradient(180deg, #f7d98a, #edc260, #dca43c);
  --g-hero: linear-gradient(135deg, #5c4613, #32260b, #17120a);
  --g-table-header: linear-gradient(180deg, #4a3a14, #2a210c);
  --g-tile: linear-gradient(180deg, #1d1d1d, #101010);
  --g-price-card: linear-gradient(180deg, #2a210c, #0f0c06);
  --g-login: radial-gradient(circle 520px at 50% 30%, #2a1f08 0%, #0a0805 55%, #050505 100%);
  --g-wordmark: linear-gradient(180deg, #f7d98a, #e0ae45, #b07f22);
  /* bo góc / lề */
  --r-card: 16px;
  --r-control: 14px;
  --r-chip: 12px;
  --r-tabbar: 24px;
  --side: 16px;
  --tabbar-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* chữ (Font.sv*) */
  --font: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Khmer UI",
    "Noto Sans Khmer", "Khmer Sangam MN", sans-serif;
  --font-serif: ui-serif, "New York", "Times New Roman", "Noto Serif", Georgia, serif;
  --font-rounded: ui-rounded, -apple-system, system-ui, "SF Pro Rounded", sans-serif;
  --fs-display: 36px;
  --fs-number-lg: 30px;
  --fs-title: 24px;
  --fs-number-md: 24px;
  --fs-button: 18px;
  --fs-value: 17px;
  --fs-body: 16px;
  --fs-body-sm: 14px;
  --fs-caption: 13px;
  --fs-tab: 11px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --glow-gold: 0 4px 9px rgba(230, 176, 70, 0.35);
}

/* ---------------------------------------------------------------- nền / khung */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: #000;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  font-size: var(--fs-body);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.frame {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--bg);
  isolation: isolate;
}

@media (min-width: 460px) {
  .frame {
    border-left: 1px solid #1a1a1a;
    border-right: 1px solid #1a1a1a;
  }
}

noscript p {
  margin: 0;
  padding: 24px 16px 0;
  color: var(--text);
  text-align: center;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

:focus-visible {
  outline: 2px solid var(--gold300);
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

img {
  display: block;
}

/* lớp: màn < sheet < lớp phủ < khoá < hộp hỏi < băng mạng < màn che < toast */
.layer-stage,
.layer-sheets,
.layer-overlays,
.layer-lock,
.layer-dialogs,
.layer-cover,
.layer-toast,
.layer-net {
  position: absolute;
  inset: 0;
}

.layer-stage { z-index: 0; }
.layer-sheets { z-index: 10; pointer-events: none; }
.layer-overlays { z-index: 20; pointer-events: none; }
.layer-lock { z-index: 30; pointer-events: none; }
.layer-dialogs { z-index: 40; pointer-events: none; }
.layer-net { z-index: 45; bottom: auto; pointer-events: none; }
.layer-cover { z-index: 50; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.layer-toast { z-index: 60; pointer-events: none; }

.layer-sheets > *,
.layer-overlays > *,
.layer-lock > *,
.layer-dialogs > * {
  pointer-events: auto;
}

.page,
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.page > * {
  flex: 1;
  min-height: 0;
}

.scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.scroll::-webkit-scrollbar {
  display: none;
}

.page-body {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.page-body > .scroll {
  flex: 1;
  min-height: 0;
  padding-bottom: calc(24px + var(--safe-bottom));
}

.fatal {
  padding: 40px 16px;
  color: var(--danger);
  text-align: center;
}

/* ---------------------------------------------------------------- tiện ích */

.stack-8 { display: flex; flex-direction: column; gap: 8px; }
.stack-14 { display: flex; flex-direction: column; gap: 14px; }
.stack-16 { display: flex; flex-direction: column; gap: 16px; }
.pad-side { padding-left: var(--side); padding-right: var(--side); }
.pad-20 { padding: calc(20px + var(--safe-top)) 20px calc(20px + var(--safe-bottom)); }
.center { text-align: center; }
.muted { color: var(--text2); }
.gold { color: var(--gold400); }
.danger { color: var(--danger); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; word-break: break-all; }
.screen-title { font-size: var(--fs-title); font-weight: 700; color: var(--text); }
.body { font-size: var(--fs-body); font-weight: 500; }
.body-strong { font-size: var(--fs-body); font-weight: 600; color: var(--text); }
.body-sm { font-size: var(--fs-body-sm); }
.caption { font-size: var(--fs-caption); color: var(--text3); }
.caption.danger { color: var(--danger); }
.tabbar-spacer { height: calc(var(--tabbar-h) + 24px + var(--safe-bottom)); flex: none; }
.bg-login { background: var(--g-login); }

/* ---------------------------------------------------------------- nút */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  padding: 0 16px;
  border-radius: var(--r-control);
  font-size: var(--fs-button);
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: transform 0.12s ease-out, opacity 0.12s ease-out;
}

.btn:active:not(:disabled) {
  opacity: 0.85;
  transform: scale(0.98);
}

.btn-ic {
  display: inline-flex;
  align-items: center;
}

.btn-ic:empty {
  display: none;
}

.btn-gold {
  background: var(--g-gold-button);
  color: var(--on-gold);
  box-shadow: var(--glow-gold), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.btn-outline {
  background: rgba(0, 0, 0, 0.4);
  color: var(--text);
  border: 1.5px solid #d9ae55;
  font-weight: 500;
}

.btn.is-off {
  opacity: 0.4;
  box-shadow: none;
}

.btn.narrow {
  max-width: 220px;
}

.text-btn {
  font-size: 15px;
  font-weight: 500;
  padding: 6px 0;
}

.text-btn.tone-gold { color: var(--gold400); }
.text-btn.tone-muted { color: var(--text3); font-size: var(--fs-caption); }

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--gold400);
  border-radius: 12px;
}

.icon-btn.sm {
  width: 36px;
  height: 36px;
}

.icon-btn:active {
  opacity: 0.7;
}

.badge-dot {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--badge);
}

.spinner {
  display: inline-block;
  flex: none;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--gold400);
  animation: spin 0.8s linear infinite;
}

.spinner.on-gold {
  border-color: rgba(36, 24, 4, 0.25);
  border-top-color: var(--on-gold);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------- chip / ngôn ngữ */

.chip {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 8px;
  border-radius: var(--r-chip);
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  color: var(--text);
  font-size: 14px;
  transition: transform 0.12s ease-out, opacity 0.12s ease-out;
}

.chip.is-on {
  background: var(--g-gold-button);
  border-color: transparent;
  color: var(--on-gold);
  font-weight: 600;
  box-shadow: 0 0 7px rgba(230, 176, 70, 0.35);
}

.chip:active {
  opacity: 0.85;
  transform: scale(0.98);
}

.chip-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flag {
  width: 20px;
  height: 14px;
  border-radius: 3px;
  flex: none;
}

.lang-chips {
  display: flex;
  gap: 10px;
}

/* minimumScaleFactor 0.8 của iOS: chữ chip co theo bề ngang khung (≥ 11,5px) thay vì bị cắt */
.lang-chips .chip {
  flex: 1 1 auto;
  gap: 6px;
  padding: 0 6px;
  font-size: clamp(11.5px, 3.3vw, 14px);
}

@media (min-width: 430px) {
  .lang-chips .chip {
    font-size: 14px;
  }
}

/* ---------------------------------------------------------------- logo */

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-splash {
  flex-direction: column;
  gap: 18px;
}

.brand-splash .brand-mark {
  width: 100%;
  max-width: 230px;
  height: auto;
}

.brand-word {
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: 0.12em;
  white-space: nowrap;
  background: var(--g-wordmark);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-splash .brand-word {
  font-size: 40px;
}

.brand-header .brand-mark {
  width: auto;
}

/* ---------------------------------------------------------------- đầu trang / vỏ */

.shell {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.shell-body {
  position: relative;
  flex: 1;
  min-height: 0;
}

.shell-body > * {
  height: 100%;
}

.app-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(64px + var(--safe-top));
  padding: var(--safe-top) 6px 0;
}

.sub-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: calc(56px + var(--safe-top));
  padding: var(--safe-top) 6px 0;
}

.sub-title {
  font-size: 18px;
  font-weight: 600;
}

.staff-header {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: calc(60px + var(--safe-top));
  padding: var(--safe-top) var(--side) 0;
}

.staff-who {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.staff-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.staff-shell .segmented {
  margin-bottom: 8px;
}

.tab-body {
  height: 100%;
  padding-top: 4px;
}

/* ---------------------------------------------------------------- thanh tab nổi */

.tab-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(8px + var(--safe-bottom));
  height: var(--tabbar-h);
  display: flex;
  overflow: hidden;
  border-radius: var(--r-tabbar);
  background: var(--g-tile);
  border: 1px solid var(--border-subtle);
  z-index: 2;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--tab-idle);
  font-size: var(--fs-tab);
  font-weight: 500;
}

.tab.is-on {
  color: var(--gold400);
  background: radial-gradient(46px at 50% 100%, rgba(230, 176, 70, 0.32), rgba(230, 176, 70, 0));
}

.tab-ic {
  position: relative;
  height: 26px;
  display: flex;
  align-items: center;
}

.tab-ic .badge-dot {
  top: -1px;
  right: -4px;
}

.tab-label {
  white-space: nowrap;
}
