:root {
  color-scheme: light;
  --ink: #222723;
  --muted: #667069;
  --line: #d9ded9;
  --surface: #ffffff;
  --canvas: #f3f5f2;
  --jade: #176b57;
  --jade-dark: #105442;
  --red: #982f40;
  --red-dark: #772331;
  --gold: #a66e13;
  --charcoal: #292d2a;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 15px; line-height: 1.5; letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
a { color: inherit; }

.user-header {
  position: sticky;
  z-index: 10;
  top: 0;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(120px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 10px max(24px, calc((100vw - 1180px) / 2));
  color: #fff;
  background: var(--charcoal);
  border-bottom: 3px solid var(--red);
}
.user-brand { display: inline-flex; align-items: center; gap: 11px; width: max-content; text-decoration: none; }
.user-brand strong, .user-brand small { display: block; }
.user-brand small { color: #c8ceca; font-size: 12px; }
.brand-mark { display: grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; border-radius: 6px; color: #fff; background: var(--red); font: 800 16px/1 Georgia, serif; }
.user-nav { display: flex; align-items: center; gap: 8px; }
.user-nav a { min-height: 38px; display: inline-flex; align-items: center; padding: 0 12px; color: #dce1dd; text-decoration: none; border-bottom: 2px solid transparent; }
.user-nav a:hover, .user-nav a:focus-visible { color: #fff; border-color: #fff; }
.user-nav a.active { color: #fff; border-color: #d56a7b; background: rgba(255, 255, 255, .06); }
.user-actions { justify-self: end; display: flex; align-items: center; gap: 10px; }
.user-actions form { margin: 0; }
.language-switch { display: inline-flex; align-items: center; overflow: hidden; border: 1px solid #68716b; border-radius: 5px; }
.language-switch a { min-width: 34px; min-height: 32px; display: inline-flex; align-items: center; justify-content: center; padding: 4px 7px; color: #dce1dd; font-size: 10px; font-weight: 800; text-decoration: none; }
.language-switch a + a { border-left: 1px solid #68716b; }
.language-switch a:hover { color: #fff; background: rgba(255,255,255,.08); }
.language-switch a.active { color: #fff; background: var(--jade); }
.auth-language-switch { position: fixed; z-index: 5; top: 18px; right: 20px; color: var(--ink); border-color: var(--line); background: #fff; }
.auth-language-switch a { color: var(--muted); }
.auth-language-switch a + a { border-color: var(--line); }
.auth-language-switch a:hover { color: var(--ink); background: #f1f4f2; }

.user-main { width: min(1180px, calc(100% - 32px)); margin: 28px auto 52px; }
.account-hero { display: flex; justify-content: space-between; align-items: end; gap: 24px; padding: 28px 0 30px; border-bottom: 1px solid var(--line); }
.account-home-hero { padding-top: 36px; }
.eyebrow { margin: 0 0 5px; color: var(--red); font-size: 11px; font-weight: 800; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: 32px; line-height: 1.2; font-weight: 750; }
h2 { margin: 0; font-size: 22px; line-height: 1.25; }
h3 { margin: 0; font-size: 17px; }
.account-id { margin: 7px 0 0; color: var(--muted); }
.account-id span { padding: 0 4px; }
.balance-block { min-width: 150px; text-align: right; }
.balance-block span, .balance-block small { display: block; color: var(--muted); }
.balance-block strong { color: var(--jade); font-size: 34px; line-height: 1.1; }

.feature-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 28px; }
.feature-tile { min-width: 0; min-height: 168px; display: grid; grid-template-columns: minmax(0, 1fr) 24px; grid-template-rows: auto 1fr; gap: 18px 12px; padding: 22px; border: 1px solid rgba(0, 0, 0, .08); border-radius: 4px; color: #fff; text-decoration: none; box-shadow: 0 1px 2px rgba(23, 31, 26, .1); transition: transform .16s ease, box-shadow .16s ease; }
.feature-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(23, 31, 26, .16); }
.feature-tile:focus-visible { outline: 3px solid rgba(23, 107, 87, .24); outline-offset: 3px; }
.feature-tile-wallet { background: #116855; }
.feature-tile-profile { background: #285f96; }
.feature-tile-security { background: #91384a; }
.feature-tile-giftcode { background: #8b641d; }
.feature-icon { width: 36px; height: 36px; grid-column: 1 / -1; }
.feature-copy { min-width: 0; align-self: end; }
.feature-copy strong, .feature-copy small { display: block; overflow-wrap: anywhere; }
.feature-copy strong { font-size: 17px; line-height: 1.3; }
.feature-copy small { margin-top: 4px; color: rgba(255, 255, 255, .78); font-size: 12px; }
.feature-arrow { width: 21px; height: 21px; align-self: end; }

.function-heading { padding: 8px 0 4px; }
.back-link { min-height: 36px; display: inline-flex; align-items: center; gap: 6px; margin-bottom: 22px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 700; }
.back-link:hover { color: var(--jade); }
.back-link:focus-visible { outline: 2px solid rgba(23, 107, 87, .3); outline-offset: 2px; }
.back-link svg { width: 18px; height: 18px; }
.function-title-row { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.function-section { margin-top: 20px; }
.user-section-narrow { max-width: 720px; }

.user-section { margin-top: 0px; padding: 26px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; }
.section-heading.compact { margin-bottom: 18px; }
.section-heading > span { color: var(--muted); font-size: 13px; }
.balance-pill, .status { display: inline-flex; align-items: center; min-height: 28px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.balance-pill { color: var(--jade-dark) !important; background: #e7f2ee; }

.withdraw-form, .giftcode-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: end; }
.withdraw-form { padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.giftcode-form .button-primary { justify-self: start; }
.role-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.field { display: grid; gap: 7px; min-width: 0; }
.field > span { color: #444b46; font-size: 13px; font-weight: 700; }
.field-hint { min-height: 18px; color: var(--muted); font-size: 12px; }
.field-hint.is-success { color: var(--jade); }
.field-hint.is-error { color: var(--red); }
.field input, .field select { width: 100%; min-height: 44px; padding: 9px 11px; color: var(--ink); background: #fff; border: 1px solid #bac2bc; border-radius: 5px; outline: none; }
.field input:focus, .field select:focus { border-color: var(--jade); box-shadow: 0 0 0 3px rgba(23, 107, 87, .14); }
.field input:disabled, .field select:disabled { color: #7d847f; background: #eef0ee; }
.stack-form { display: grid; gap: 16px; }
.form-status { min-height: 24px; color: var(--muted); font-size: 13px; }
.form-status.is-success { color: var(--jade); }
.form-status.is-warning { color: var(--gold); }
.form-status.is-error { color: var(--red); }

.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; padding: 8px 16px; border: 1px solid transparent; border-radius: 5px; cursor: pointer; font-weight: 750; text-decoration: none; }
.button:hover { filter: brightness(.96); }
.button:focus-visible { outline: 3px solid rgba(23, 107, 87, .22); outline-offset: 2px; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button-primary { color: #fff; background: var(--jade); }
.button-secondary { color: var(--ink); background: #fff; border-color: #aeb6b0; }
.button-danger { color: #fff; background: var(--red); }
.button-ghost { color: #fff; background: transparent; border-color: #68716b; }
.button-small { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.button-wide { width: 100%; }

.history-block { margin-top: 24px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { color: #535b55; background: #f2f4f2; font-size: 12px; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { margin-top: 3px; max-width: 360px; color: var(--muted); }
code { font-family: Consolas, monospace; font-size: 11px; }
.empty { padding: 28px; color: var(--muted); text-align: center; }
.status-delivered { color: var(--jade-dark); background: #dff0e9; }
.status-processing { color: #77500f; background: #fff0cf; }
.status-failed { color: #7d2936; background: #f8e1e5; }

.alert { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 0 0 16px; padding: 12px 14px; border: 1px solid; border-radius: 6px; }
.alert button { width: 28px; height: 28px; padding: 0; color: inherit; background: transparent; border: 0; cursor: pointer; font-size: 22px; }
.alert-success { color: #145743; background: #e4f3ed; border-color: #a8d4c5; }
.alert-danger, .alert-error { color: #792332; background: #fae8eb; border-color: #e6adb7; }
.alert-warning { color: #775000; background: #fff8e7; border-color: #e6cd96; }
.alert-info { color: #1d536f; background: #eff8fc; border-color: #b7d4e5; }
.alert .btn-close { background: transparent var(--bs-btn-close-bg) center/1em auto no-repeat; font-size: initial; }

.auth-page { min-height: 100vh; background: #e9ede9; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(430px, 100%); padding: 30px; background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--red); border-radius: 8px; box-shadow: 0 18px 50px rgba(28, 35, 30, .12); }
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 25px; }
.login-brand p { margin: 0 0 3px; color: var(--red); font-size: 11px; font-weight: 800; }
.login-brand h1 { font-size: 25px; }
.secondary-link { display: block; margin-top: 18px; color: var(--jade); text-align: center; font-weight: 700; }
.error-panel { text-align: center; }
.error-panel p { color: var(--muted); }
.error-code { color: var(--red); font: 800 44px/1 Georgia, serif; }

@media (max-width: 760px) {
  .user-header { position: static; grid-template-columns: 1fr auto; gap: 10px; padding: 10px 16px; }
  .user-nav { grid-column: 1 / -1; grid-row: 2; overflow-x: auto; border-top: 1px solid #4a504c; }
  .user-nav a { flex: 1; justify-content: center; white-space: nowrap; }
  .user-actions { gap: 6px; }
  .user-actions .button { padding-left: 10px; padding-right: 10px; }
  .user-main { width: min(100% - 20px, 1180px); margin-top: 14px; }
  .account-hero { align-items: start; padding: 20px 4px; }
  h1 { font-size: 27px; }
  .balance-block { min-width: 90px; }
  .balance-block strong { font-size: 28px; }
  .feature-grid { grid-template-columns: 1fr; gap: 10px; margin-top: 16px; }
  .feature-tile { min-height: 118px; padding: 17px; gap: 11px; }
  .feature-icon { width: 29px; height: 29px; }
  .function-heading { padding: 6px 4px 0; }
  .user-section { margin-top: 16px; padding: 18px 14px; }
  .withdraw-form, .giftcode-form { grid-template-columns: 1fr; }
  .section-heading { align-items: start; }
}

@media (max-width: 440px) {
  .user-brand small { display: none; }
  .role-control { grid-template-columns: 1fr; }
  .account-hero { display: grid; }
  .balance-block { text-align: left; }
  .function-title-row { display: grid; }
  .function-title-row .balance-pill { width: max-content; }
  .login-panel { padding: 24px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .feature-tile { transition: none; }
}
