/* ==========================================================================
   AURUM — Bảng giá vàng
   Public page: luxury dark + gold
   Admin page: clean utility
   ========================================================================== */

:root {
  /* Public page — White / Cream theme (Bảo Tín Mạnh Hải style) */
  --bg: #ffffff;
  --bg-2: #fafaf7;
  --surface: #ffffff;       /* row trắng */
  --surface-2: #fbf3e7;     /* row kem */
  --line: #ece4d3;
  --line-strong: #d6c9a8;

  --gold: #b88a3a;          /* gold trầm hơn để đọc tốt trên trắng */
  --gold-bright: #c99a4a;
  --gold-deep: #8a6520;
  --gold-glow: rgba(184, 138, 58, 0.25);

  --red: #9c131d;           /* màu đỏ nhấn cho tiêu đề và viền */
  --red-deep: #7a0e16;

  --text: #2a1a0d;
  --text-soft: #5a4632;
  --text-mute: #8b7860;

  --buy: #2a1a0d;
  --sell: #b88a3a;

  --radius: 4px;
  --radius-lg: 8px;

  --font-display: 'Playfair Display', 'Times New Roman', serif;
  --font-body: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

/* Đảm bảo thuộc tính HTML `hidden` luôn ẩn hoàn toàn, không bị
   các rule layout (flex, min-height...) ghi đè. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

body { position: relative; overflow-x: hidden; }

/* ============== Decorative background ============== */

.bg-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(80% 50% at 50% 0%, rgba(184, 138, 58, 0.05), transparent 60%),
    linear-gradient(180deg, #ffffff 0%, #fdfaf3 100%);
}

main, header, footer { position: relative; z-index: 1; }

/* ============== Header ============== */

.site-header {
  padding: 28px 0 0;
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  display: block;
  height: 88px;
  width: auto;
  transition: transform 0.3s ease;
}

.brand-logo:hover {
  transform: scale(1.04);
}

.meta-label {
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.meta-value {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-soft);
  letter-spacing: 0.04em;
}

.header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.header-divider {
  max-width: 1180px;
  margin: 24px auto 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(184, 138, 58, 0.35) 20%,
    rgba(184, 138, 58, 0.55) 50%,
    rgba(184, 138, 58, 0.35) 80%,
    transparent 100%
  );
  opacity: 0.7;
}

/* ============== Container ============== */

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 56px 32px 80px;
}

/* ============== Hero ============== */

.hero {
  text-align: center;
  margin-bottom: 20px;
  animation: rise 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.hero-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 0px;
  animation: float 4s ease-in-out infinite;
}

.hero-logo img {
  height: 400px;
  width: auto;
  max-width: 80%;
  filter: drop-shadow(0 12px 24px rgba(184, 138, 58, 0.18));
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(44px, 8vw, 92px);
  line-height: 1.3;
  letter-spacing: 0.005em;
  margin: 0;
  white-space: nowrap;
  background: linear-gradient(180deg, #c99a4a 0%, #b88a3a 50%, #8a6520 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  /* Fallback nếu trình duyệt không hỗ trợ background-clip */
  -webkit-text-fill-color: transparent;
}

/* Subtitle text + nút làm mới gộp thành 1 dòng nhỏ gọn */
.subtitle-text {
  font-size: 12px;
  color: var(--text-mute);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.subtitle-text strong {
  color: var(--gold-deep);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 12px;
}

.subtitle-sep {
  color: var(--line-strong);
  font-size: 12px;
}

.hero-actions {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Buttons - compact */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn--gold {
  background: linear-gradient(180deg, #fff8ea, #fbedd0);
  color: var(--gold-deep);
  border-color: var(--gold);
}

.btn--gold:hover {
  background: linear-gradient(180deg, #fff3d9, #f5e0b1);
  border-color: var(--gold-deep);
  box-shadow: 0 4px 14px rgba(184, 138, 58, 0.18);
  transform: translateY(-1px);
}

.btn-icon {
  display: flex;
  transition: transform 0.5s ease;
}

.btn.is-spinning .btn-icon {
  animation: spin 0.6s linear;
}

/* Status pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}

.status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2dbe5e;
  box-shadow: 0 0 6px rgba(45, 190, 94, 0.5);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* ============== Board / Table ============== */

.board {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 4px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 12px 40px -12px rgba(184, 138, 58, 0.15),
    0 2px 8px rgba(0, 0, 0, 0.04);
  animation: rise 1s 0.1s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.board::before {
  content: '';
  position: absolute;
  top: 0;
  left: 5%;
  right: 5%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.board-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  transition: opacity 0.2s ease;
}

.price-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-body);
}

.price-table thead th {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold-deep);
  text-align: left;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line-strong);
  background: var(--surface-2);
}

.price-table thead th.col-price {
  text-align: right;
}

.price-table tbody tr {
  border-bottom: 1px solid rgba(184, 138, 58, 0.08);
  transition: background 0.2s ease;
  animation: rowIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--row-i, 0) * 60ms);
  background: var(--surface);
}

.price-table tbody tr:nth-child(even) {
  background: var(--surface-2);
}

.price-table tbody tr:hover {
  background: #fbedd0;
}

.price-table tbody tr:last-child {
  border-bottom: none;
}

.price-table td {
  padding: 20px 28px;
  font-size: 15px;
  vertical-align: middle;
}

.col-name {
  display: flex;
  align-items: center;
  gap: 14px;
}

.row-bullet {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
  box-shadow: 0 0 4px rgba(184, 138, 58, 0.4);
}

.row-name {
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0.005em;
}

.col-price {
  text-align: right;
  white-space: nowrap;
}

.price {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 17px;
  color: var(--text);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.price--sell {
  color: var(--gold-deep);
}

.empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-mute);
  font-style: italic;
}

/* Loader */
.loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 5;
  color: var(--text-soft);
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(2px);
  border-radius: var(--radius-lg);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 2px solid rgba(184, 138, 58, 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

/* Error box */
.error-box {
  margin: 12px;
  padding: 16px 20px;
  border: 1px solid rgba(220, 60, 60, 0.3);
  background: #fff5f5;
  border-radius: var(--radius);
  color: #b03030;
  font-size: 13px;
}

.error-box strong { color: #8a2020; margin-right: 8px; }

/* Board footer */
.board-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 22px 24px 20px;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold-deep);
  background: var(--surface-2);
  border-top: 1px solid var(--line);
}

.dash {
  flex: 1;
  max-width: 80px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
}

.footer-note {
  white-space: nowrap;
}

/* Site footer */
.site-footer {
  padding: 32px 32px 40px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.footer-inner {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-sep { opacity: 0.5; }

/* ============== Animations ============== */

@keyframes rise {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes rowIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

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

/* ============== Responsive ============== */

@media (max-width: 720px) {
  .header-inner { padding: 0 20px; flex-direction: column; align-items: flex-start; gap: 14px; }
  .header-meta { align-items: flex-start; }
  .brand-logo { height: 64px; }
  .container { padding: 36px 16px 60px; }
  .hero-logo img { height: 130px; }
  .title { font-size: clamp(36px, 11vw, 56px); }
  .price-table thead th { padding: 14px 16px; font-size: 10px; letter-spacing: 0.24em; }
  .price-table td { padding: 14px 16px; font-size: 13px; }
  .price { font-size: 14px; }
  .col-name { gap: 10px; }
  .row-name { font-size: 13px; line-height: 1.35; }
  .board-footer { padding: 16px; gap: 10px; }
  .dash { max-width: 30px; }
  .footer-note { font-size: 9px; letter-spacing: 0.2em; white-space: normal; text-align: center; }
}

@media (max-width: 420px) {
  .price-table thead th:first-child,
  .price-table td:first-child { padding-left: 12px; }
  .price-table thead th:last-child,
  .price-table td:last-child { padding-right: 12px; }
  .hero-logo img { height: 110px; }
  .title { font-size: 38px; }
}

/* =========================================================================
   ADMIN PAGE
   ========================================================================= */

html:has(body.page-admin),
body.page-admin {
  background: var(--bg);
  color: var(--text);
}

.page-admin {
  background: #0e0e12;
  color: var(--text);
}

.admin-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 28px 80px;
  position: relative;
  z-index: 1;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}

.admin-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  margin: 0;
  letter-spacing: 0.02em;
}

.admin-title em {
  color: var(--gold);
  font-style: italic;
}

.admin-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-back {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-soft);
  text-decoration: none;
  border: 1px solid var(--line);
  padding: 8px 16px;
  border-radius: 999px;
  transition: all 0.2s ease;
  font-family: var(--font-body);
  background: transparent;
  cursor: pointer;
}

.admin-back:hover {
  color: var(--gold);
  border-color: var(--gold);
}

.admin-back--logout {
  border-color: rgba(255, 120, 120, 0.25);
  color: #e9b9b9;
}
.admin-back--logout:hover {
  color: #ff9b9b;
  border-color: rgba(255, 120, 120, 0.6);
}

.card {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text);
}

.card-sub {
  font-size: 13px;
  color: var(--text-mute);
  margin: 0 0 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field label {
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.field input {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.field input:focus {
  border-color: var(--gold);
  background: var(--surface-2);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.btn--primary {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #1a1208;
  border: 1px solid var(--gold);
  font-weight: 600;
}
.btn--primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 0 24px rgba(212, 168, 83, 0.35);
  transform: translateY(-1px);
}

.btn--ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--text);
}
.btn--ghost:hover { border-color: var(--gold); color: var(--gold-bright); }

.btn--danger {
  background: transparent;
  border: 1px solid rgba(255, 100, 100, 0.3);
  color: #ff9b9b;
  padding: 6px 12px;
  font-size: 11px;
  letter-spacing: 0.18em;
}
.btn--danger:hover {
  border-color: rgba(255, 100, 100, 0.7);
  background: rgba(255, 80, 80, 0.08);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.admin-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-mute);
  padding: 10px 8px;
  border-bottom: 2px solid var(--line-strong);
}

.admin-table td {
  padding: 8px;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}

.admin-table input[type="text"] {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
}

.admin-table input[type="text"]:focus { border-color: var(--gold); }

.admin-table .col-num { width: 40px; color: var(--text-mute); font-family: var(--font-mono); font-size: 13px; text-align: center; }
.admin-table .col-action { width: 80px; text-align: right; }

.toast {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid var(--line);
}

.toast--ok { color: #b8eccd; border-color: rgba(80, 220, 120, 0.3); background: rgba(80, 220, 120, 0.06); }
.toast--err { color: #ffb8b8; border-color: rgba(255, 100, 100, 0.3); background: rgba(255, 80, 80, 0.06); }
.toast--info { color: var(--gold-bright); border-color: rgba(212, 168, 83, 0.3); background: rgba(212, 168, 83, 0.06); }

@media (max-width: 720px) {
  .admin-shell { padding: 24px 16px 60px; }
  .admin-table .col-num { display: none; }
  .admin-table th, .admin-table td { padding: 6px 4px; }
  .admin-table input[type="text"] { font-size: 13px; padding: 8px 10px; }
  .actions-row .btn { width: 100%; justify-content: center; }
  .actions-spacer { display: none; }
}

/* =========================================================================
   LOGIN SCREEN
   ========================================================================= */

.actions-spacer {
  flex: 1;
  min-width: 0;
}

.btn--full {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

.login-screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background:
    radial-gradient(60% 40% at 80% -10%, rgba(212, 168, 83, 0.1), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px 36px 32px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 30px 80px -30px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(212, 168, 83, 0.05);
  position: relative;
  text-align: center;
  animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-glow), transparent);
}

.login-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 12px rgba(212, 168, 83, 0.25));
}

.login-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  margin: 0 0 8px;
  letter-spacing: 0.01em;
  color: var(--text);
}

.login-sub {
  font-size: 13px;
  color: var(--text-mute);
  margin: 0 0 28px;
}

.login-card .field { text-align: left; }

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-back {
  display: inline-block;
  margin-top: 22px;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-mute);
  text-decoration: none;
  transition: color 0.2s ease;
}

.login-back:hover { color: var(--gold); }

@media (max-width: 480px) {
  .login-card { padding: 32px 22px 26px; }
  .login-title { font-size: 22px; }
}
