:root {
  --gold-dark: #8A5F1D;
  --gold-mid: #C99A3D;
  --gold-light: #E5C46B;
  --gold-pale: #F8F0DC;
  --ink: #1f160c;
  --ink-muted: #6a5638;
  --card: #FFFEFA;
  --chip: #F4EAD0;
  --border: rgba(138, 95, 29, 0.18);
  --bg: #f3eee3;
  --bg-deep: #ebe4d4;
  --success: #1f6b4a;
  --danger: #a33a3a;
  --fin: #3b5bdb;
  --radius: 18px;
  --shadow: 0 12px 40px rgba(42, 31, 18, 0.07);
  --shadow-sm: 0 4px 16px rgba(42, 31, 18, 0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(229, 196, 107, 0.25), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(138, 95, 29, 0.08), transparent 50%),
    var(--bg);
  line-height: 1.55;
  min-height: 100vh;
}

/* Topbar */
.topbar {
  background: linear-gradient(135deg, #7a5218 0%, #C99A3D 40%, #E8C97A 52%, #C99A3D 70%, #7a5218 100%);
  color: #fff;
  padding: 0.85rem 1.35rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(90, 60, 20, 0.22);
}
.topbar-inner {
  max-width: 1140px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.logo {
  font-weight: 750;
  font-size: 1.25rem;
  letter-spacing: 0.4px;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}
.logo span { font-weight: 400; opacity: 0.88; font-size: 0.82rem; }
.nav-main { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.nav-main button {
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.42rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.18s ease;
  backdrop-filter: blur(6px);
}
.nav-main button:hover { background: rgba(255,255,255,0.22); }
.nav-main button.active {
  background: #fff;
  color: var(--gold-dark);
  border-color: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}
.user-chip {
  font-size: 0.76rem;
  font-weight: 600;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.28);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
}

.wrap { max-width: 1140px; margin: 0 auto; padding: 1.35rem 1.2rem 3.5rem; }
.view { display: none; animation: fadeIn 0.25s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.unit-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.35px;
  color: var(--gold-dark);
  background: linear-gradient(180deg, #fff, var(--gold-pale));
  border: 1px solid var(--border);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow-sm);
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.15rem;
  overflow: hidden;
  position: relative;
}
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold-mid), transparent 70%);
}
.card-h {
  padding: 1rem 1.25rem 0.8rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.card-h h2 {
  font-size: 1.08rem;
  color: var(--gold-dark);
  font-weight: 750;
  letter-spacing: -0.01em;
}
.card-b { padding: 1.15rem 1.25rem 1.35rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.9rem; }
@media (max-width: 880px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 0.7rem; }
.kpi {
  background: linear-gradient(165deg, #fff 0%, var(--gold-pale) 160%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem 0.95rem;
  box-shadow: var(--shadow-sm);
}
.kpi .l {
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.75px;
  text-transform: uppercase;
  color: var(--gold-mid);
}
.kpi .v { font-size: 1.2rem; font-weight: 750; color: var(--ink); margin-top: 0.2rem; letter-spacing: -0.02em; }
.kpi .s { font-size: 0.74rem; color: var(--ink-muted); margin-top: 0.12rem; }

label { display: block; font-size: 0.76rem; font-weight: 650; color: var(--ink-muted); margin-bottom: 0.28rem; }
input, select, textarea {
  width: 100%;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 11px;
  font-size: 0.9rem;
  background: #fff;
  color: var(--ink);
  transition: 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold-mid);
  box-shadow: 0 0 0 3px rgba(201, 154, 61, 0.2);
}
.field { margin-bottom: 0.8rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.58rem 1.15rem;
  border-radius: 11px;
  font-size: 0.88rem;
  font-weight: 650;
  border: none;
  cursor: pointer;
  transition: 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--gold-mid), var(--gold-dark));
  color: #fff;
  box-shadow: 0 6px 18px rgba(138, 95, 29, 0.28);
}
.btn-primary:hover { box-shadow: 0 8px 22px rgba(138, 95, 29, 0.36); filter: brightness(1.03); }
.btn-ghost {
  background: #fff;
  color: var(--gold-dark);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--chip); }
.btn-danger { background: #fdecea; color: var(--danger); border: 1px solid #f0c4c4; }
.btn-sm { padding: 0.38rem 0.75rem; font-size: 0.78rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none; }

/* Products */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
}
.product-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: 0.2s ease;
  box-shadow: var(--shadow-sm);
}
.product-card:hover {
  border-color: rgba(201, 154, 61, 0.55);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.product-card .ph {
  height: 108px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--chip), var(--gold-pale) 60%, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  color: var(--gold-dark);
  font-weight: 700;
  letter-spacing: 0.3px;
}
.product-card h3 { font-size: 0.95rem; font-weight: 700; letter-spacing: -0.01em; margin-top: 0.15rem; }
.product-card .price { font-size: 1.12rem; font-weight: 750; color: var(--gold-dark); }
.product-card .meta { font-size: 0.74rem; color: var(--ink-muted); }

.tbl { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.tbl th {
  text-align: left;
  font-size: 0.66rem;
  letter-spacing: 0.55px;
  text-transform: uppercase;
  color: var(--gold-mid);
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--border);
}
.tbl td {
  padding: 0.6rem 0.4rem;
  border-bottom: 1px solid rgba(138, 95, 29, 0.07);
  vertical-align: top;
}
.tbl tr:last-child td { border-bottom: none; }

.tag {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 750;
  padding: 0.16rem 0.48rem;
  border-radius: 6px;
  background: var(--chip);
  color: var(--gold-dark);
}
.tag.ok { background: #e2f5eb; color: var(--success); }
.tag.warn { background: #fdecea; color: var(--danger); }
.tag.fin { background: #e8eefd; color: var(--fin); }
.tag.svc { background: #f0e8ff; color: #6b4bb3; }

.hint { font-size: 0.78rem; color: var(--ink-muted); line-height: 1.45; }
.empty { text-align: center; color: var(--ink-muted); font-size: 0.88rem; padding: 1.3rem; }

.gate {
  max-width: 420px;
  margin: 2.2rem auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}
.gate h2 { color: var(--gold-dark); margin-bottom: 0.45rem; font-size: 1.2rem; }

.toast {
  position: fixed;
  bottom: 1.35rem;
  right: 1.35rem;
  z-index: 200;
  background: var(--ink);
  color: #fff;
  padding: 0.8rem 1.15rem;
  border-radius: 12px;
  font-size: 0.85rem;
  max-width: 340px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.22);
  opacity: 0;
  transform: translateY(14px);
  transition: 0.28s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

.cart-count {
  background: #fff;
  color: var(--gold-dark);
  font-size: 0.68rem;
  font-weight: 750;
  min-width: 1.15rem;
  height: 1.15rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.25rem;
}

.section-label {
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold-mid);
  margin: 1.15rem 0 0.55rem;
}

.bal-split { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
@media (max-width: 560px) { .bal-split { grid-template-columns: 1fr; } }

.bal-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  box-shadow: var(--shadow-sm);
}
.bal-box strong { font-size: 1.08rem; }

.disclaimer {
  margin-top: 1.4rem;
  padding: 1rem 1.2rem;
  background: linear-gradient(180deg, #fff, var(--gold-pale));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.78rem;
  color: var(--ink-muted);
  box-shadow: var(--shadow-sm);
}
.disclaimer strong { color: var(--gold-dark); }

.ship-opt, .pay-opt {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  background: #fff;
  transition: 0.15s;
}
.ship-opt:hover, .pay-opt:hover,
.ship-opt.selected, .pay-opt.selected {
  border-color: var(--gold-mid);
  background: linear-gradient(180deg, #fff, var(--gold-pale));
  box-shadow: var(--shadow-sm);
}
.ship-opt.blocked, .pay-opt.blocked {
  opacity: 0.48;
  cursor: not-allowed;
  background: #f7f5f0;
}
.pay-opt .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.bar-row { margin-bottom: 0.7rem; }
.bar-label { display: flex; justify-content: space-between; font-size: 0.78rem; margin-bottom: 0.22rem; }
.bar-track { height: 11px; background: var(--chip); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--gold-mid), var(--gold-dark)); }
.bar-fill.fiat { background: linear-gradient(90deg, #7a9bb8, #3d5a80); }
.bar-fill.fin { background: linear-gradient(90deg, #8da2e8, #3b5bdb); }

/* Help cards */
.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.85rem;
}
.help-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow-sm);
}
.help-card h3 {
  font-size: 0.92rem;
  color: var(--gold-dark);
  margin-bottom: 0.35rem;
  font-weight: 750;
}
.help-card p { font-size: 0.8rem; color: var(--ink-muted); }

.checkout-panel {
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
  padding-top: 0.25rem;
}

.wallet-hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
@media (max-width: 800px) { .wallet-hero { grid-template-columns: 1fr; } }

.pill-note {
  display: inline-block;
  font-size: 0.72rem;
  background: var(--chip);
  color: var(--gold-dark);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-weight: 650;
  margin-top: 0.35rem;
}

.top-right-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  min-width: 150px;
}
.top-right-stack select {
  width: 100%;
  background: rgba(255,255,255,.95);
  border: none;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gold-dark);
}
.top-right-stack .btn-wallet {
  width: 100%;
  background: #fff !important;
  color: var(--gold-dark) !important;
  border: none !important;
  border-radius: 999px !important;
  font-size: 0.78rem !important;
  padding: 0.35rem 0.7rem !important;
}
