:root {
  --wine: #6e2029;
  --wine-deep: #40141c;
  --gold: #bc8b36;
  --gold-bright: #e2bd68;
  --paper: #f2eadb;
  --paper-deep: #e5d7c0;
  --ink: #2d2524;
  --muted: #766b65;
  --line: rgba(111, 78, 45, .2);
  --green: #2f7b59;
  --shadow: 0 22px 70px rgba(70, 36, 21, .18);
  font-family: "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(255,255,255,.7), transparent 34rem),
    linear-gradient(135deg, #f7f1e6 0%, var(--paper) 54%, #e8dcc8 100%);
}

button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.admin-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .14;
  background-image: radial-gradient(rgba(96, 61, 37, .3) .6px, transparent .7px);
  background-size: 5px 5px;
  mix-blend-mode: multiply;
}

.admin-shell { position: relative; min-height: 100vh; }

.admin-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 84px;
  padding: 16px clamp(20px, 5vw, 78px);
  border-bottom: 1px solid rgba(95, 48, 34, .18);
  background: rgba(247, 241, 230, .82);
  backdrop-filter: blur(14px);
}

.back-link, .admin-footer a { color: var(--wine); font-weight: 800; text-decoration: none; }
.back-link { justify-self: start; letter-spacing: .03em; }
.back-link:hover, .admin-footer a:hover { color: var(--gold); }

.admin-brand { display: flex; align-items: center; gap: 11px; }
.brand-seal { width: 48px; height: 48px; padding: 3px; border: 1px solid var(--gold); border-radius: 50%; background: #fffaf0; }
.brand-seal img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.admin-brand strong { display: block; color: var(--wine); font-family: Georgia, "Songti SC", serif; font-size: 22px; letter-spacing: .14em; }
.admin-brand span { display: block; margin-top: 2px; color: var(--muted); font-family: Georgia, serif; font-size: 9px; letter-spacing: .18em; }
.admin-badge { justify-self: end; padding: 8px 13px; border: 1px solid rgba(188,139,54,.5); border-radius: 999px; color: var(--wine); font-size: 12px; font-weight: 900; letter-spacing: .12em; }

.admin-main { width: min(1280px, calc(100% - 40px)); margin: 0 auto; padding: clamp(42px, 7vw, 90px) 0 48px; }
.admin-heading { max-width: 640px; margin-bottom: 34px; }
.eyebrow, .panel-kicker { margin: 0 0 10px; color: var(--gold); font-family: Georgia, serif; font-size: 11px; font-weight: 900; letter-spacing: .24em; }
.admin-heading h1 { margin: 0; color: var(--wine-deep); font-family: Georgia, "Songti SC", serif; font-size: clamp(36px, 6vw, 64px); line-height: .98; letter-spacing: .04em; }
.admin-heading p:last-child { max-width: 560px; margin: 22px 0 0; color: var(--muted); font-size: 15px; line-height: 1.8; }

.admin-layout { display: grid; grid-template-columns: minmax(260px, .72fr) minmax(0, 1.48fr); gap: 24px; align-items: start; }
.login-panel, .dashboard-panel { border: 1px solid var(--line); border-radius: 4px; background: rgba(255, 252, 244, .78); box-shadow: var(--shadow); }
.login-panel { padding: clamp(24px, 4vw, 38px); }
.login-panel h2, .dashboard-header h2 { margin: 0; color: var(--wine-deep); font-family: Georgia, "Songti SC", serif; font-size: 30px; letter-spacing: .04em; }
.panel-note { margin: 14px 0 25px; color: var(--muted); font-size: 13px; line-height: 1.7; }
label { display: block; color: var(--muted); font-size: 13px; font-weight: 800; letter-spacing: .04em; }
label + label { margin-top: 18px; }
input { width: 100%; border: 1px solid rgba(110, 79, 48, .28); border-radius: 2px; outline: 0; background: rgba(255,255,255,.65); color: var(--ink); }
.login-panel input { margin-top: 8px; padding: 13px 14px; font-size: 16px; }
input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(188,139,54,.13); }

.primary-button, .secondary-button { min-height: 48px; border-radius: 2px; font-weight: 900; letter-spacing: .04em; transition: transform .2s ease, box-shadow .2s ease, background .2s ease; }
.primary-button { border: 1px solid var(--wine); background: var(--wine); color: #fff9ed; box-shadow: 0 9px 20px rgba(110,32,41,.18); }
.primary-button span { margin-left: 14px; font-size: 19px; }
.secondary-button { border: 1px solid rgba(110,32,41,.32); background: transparent; color: var(--wine); }
.primary-button:hover, .secondary-button:hover { transform: translateY(-1px); box-shadow: 0 12px 24px rgba(110,32,41,.18); }
.secondary-button:hover { background: rgba(110,32,41,.06); }
.login-panel .primary-button { width: 100%; margin-top: 25px; }
.login-hint { display: flex; gap: 9px; margin-top: 28px; padding-top: 17px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.6; }
.login-hint span:first-child { display: grid; flex: 0 0 17px; place-items: center; width: 17px; height: 17px; border: 1px solid var(--gold); border-radius: 50%; color: var(--gold); font-family: Georgia, serif; font-weight: 900; }

.dashboard-panel { min-width: 0; padding: clamp(22px, 4vw, 40px); }
.dashboard-header { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.mode-pill { padding: 8px 12px; border: 1px solid rgba(47,123,89,.35); border-radius: 999px; color: var(--green); background: rgba(47,123,89,.08); font-size: 12px; font-weight: 900; white-space: nowrap; }
.mode-pill.manual { border-color: rgba(110,32,41,.3); color: var(--wine); background: rgba(110,32,41,.08); }

.quote-preview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-top: 28px; overflow: hidden; border: 1px solid rgba(110,32,41,.25); background: rgba(110,32,41,.25); }
.quote-card { min-height: 190px; padding: 22px 24px; background: rgba(250,245,235,.92); }
.quote-card.buyback-card { background: rgba(245,238,223,.92); }
.quote-card-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.metal-mark { display: inline-grid; place-items: center; width: 31px; height: 31px; border: 1px solid currentColor; border-radius: 50%; color: var(--gold); font-family: Georgia, serif; font-size: 13px; }
.quote-label { margin-top: 28px; color: var(--wine); font-family: Georgia, "Songti SC", serif; font-size: 20px; font-weight: 900; }
.buyback-card .quote-label { color: var(--green); }
.quote-value { display: flex; align-items: baseline; gap: 8px; margin-top: 7px; white-space: nowrap; }
.quote-value strong { color: var(--wine); font-family: Georgia, "Times New Roman", serif; font-size: clamp(26px, 3.5vw, 42px); line-height: 1; letter-spacing: -.04em; }
.buyback-card .quote-value strong { color: var(--green); }
.quote-value span { color: var(--muted); font-size: 14px; font-weight: 800; }

.sync-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; min-height: 54px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.sync-row > div { display: flex; align-items: center; gap: 9px; }
.sync-row strong { color: var(--ink); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(47,123,89,.1); }
.status-dot.manual { background: var(--wine); box-shadow: 0 0 0 4px rgba(110,32,41,.1); }
.operator-text { color: var(--muted); }

.price-form { margin-top: 28px; }
.form-heading { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.form-heading h3 { margin: 0; color: var(--wine-deep); font-size: 18px; }
.form-heading p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.form-mark { color: var(--gold); font-family: Georgia, serif; font-size: 12px; font-weight: 900; letter-spacing: .14em; }
.price-input-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 20px; }
.price-input-field > span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 13px; font-weight: 800; }
.price-input-field > div { display: flex; align-items: center; border-bottom: 1px solid rgba(110,32,41,.42); }
.price-input-field input { width: 0; min-width: 0; flex: 1 1 auto; padding: 8px 0; border: 0; border-radius: 0; background: transparent; font-family: Georgia, "Times New Roman", serif; font-size: 30px; font-weight: 900; text-align: center; }
.price-input-field input:focus { box-shadow: none; }
.price-input-field em { color: var(--muted); font-size: 12px; font-style: normal; font-weight: 800; white-space: nowrap; }
.price-control { gap: 8px; }
.price-control .step-button { display: grid; flex: 0 0 30px; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid rgba(110,32,41,.28); border-radius: 50%; background: transparent; color: var(--wine); font-size: 20px; line-height: 1; }
.price-control .step-button:hover { background: rgba(110,32,41,.08); }
.adjustment-row { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr); gap: 12px; align-items: end; margin-top: 17px; padding: 13px 0 2px; border-top: 1px dashed var(--line); }
.adjustment-row label { position: relative; }
.adjustment-row input { width: 100%; margin-top: 7px; padding: 8px 52px 8px 10px; }
.adjustment-row small { position: absolute; right: 10px; bottom: 10px; color: var(--muted); font-size: 11px; }
.apply-adjustment { grid-column: 1 / -1; width: 100%; min-height: 42px; padding: 0 13px; white-space: nowrap; }
.form-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; margin-top: 25px; }
.form-actions .secondary-button { padding: 0 16px; }

.section-rule { height: 1px; margin: 30px 0 24px; background: var(--line); }
.account-list { margin-top: 16px; border: 1px solid var(--line); }
.account-row { display: grid; grid-template-columns: 1fr 80px 1fr; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.account-row:first-child { border-top: 0; }
.account-row strong { color: var(--ink); }
.grant-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 12px; }
.grant-form input { padding: 11px 12px; }
.grant-form button { padding: 0 13px; }

.admin-status { min-height: 25px; margin-top: 17px; color: var(--wine); font-size: 13px; font-weight: 800; }
.admin-footer { padding: 0 20px 32px; color: var(--muted); text-align: center; font-size: 12px; }

@media (max-width: 800px) {
  .admin-topbar { grid-template-columns: auto 1fr auto; padding-inline: 20px; }
  .admin-brand { justify-self: center; }
  .back-link span { display: none; }
  .admin-layout { grid-template-columns: minmax(0, 1fr); }
  .login-panel { max-width: 560px; }
  .dashboard-panel { width: 100%; }
}

@media (max-width: 520px) {
  .admin-main { width: min(100% - 24px, 480px); padding-top: 34px; }
  .admin-topbar { min-height: 70px; padding: 11px 12px; }
  .brand-seal { width: 38px; height: 38px; }
  .admin-brand strong { font-size: 17px; }
  .admin-brand span { display: none; }
  .admin-badge { padding: 6px 8px; font-size: 10px; }
  .admin-heading h1 { font-size: 40px; }
  .admin-heading p:last-child { font-size: 13px; }
  .login-panel, .dashboard-panel { padding: 22px 18px; }
  .quote-preview, .price-input-grid { grid-template-columns: 1fr; }
  .quote-card { min-height: 152px; padding: 18px; }
  .quote-label { margin-top: 18px; }
  .quote-value { gap: 4px; }
  .quote-value strong { min-width: 0; font-size: clamp(25px, 9vw, 36px); letter-spacing: -.03em; }
  .quote-value span { font-size: 12px; }
  .price-input-field input { font-size: 25px; }
  .form-actions { grid-template-columns: 1fr; }
  .form-actions .secondary-button { min-height: 43px; }
  .adjustment-row { grid-template-columns: 1fr 1fr; }
  .apply-adjustment { grid-column: 1 / -1; }
  .sync-row { align-items: start; flex-direction: column; justify-content: center; gap: 3px; padding: 9px 0; }
  .grant-form { grid-template-columns: 1fr; }
  .grant-form button { min-height: 42px; }
}
.silver-form { margin-top: 24px; border-top: 1px solid #c4ccd3; padding-top: 24px; }
.silver-form .quote-value strong { color: #52616f; font-family: "DIN Alternate", "Bahnschrift", sans-serif; }
.silver-form .adjustment-row { grid-template-columns: minmax(0, 1fr) auto; }
@media (max-width: 600px) {
  .silver-form .form-heading { align-items: flex-start; flex-direction: column; gap: 16px; }
  .silver-form .adjustment-row { grid-template-columns: 1fr; }
}

.header-banner-editor { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 24px; }
.header-banner-editor input, .header-banner-editor button { min-height: 44px; }
.header-banner-field { min-width: 0; margin-top: 18px; }
.header-banner-field > span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 13px; font-weight: 800; }
.header-banner-field > span output { color: var(--wine); font-variant-numeric: tabular-nums; }
.header-banner-field input[type="text"] { padding: 10px 12px; }
.header-banner-field select { width: 100%; min-height: 44px; padding: 10px 12px; color: var(--ink); border: 1px solid var(--line); background: #fffdf8; font: inherit; }
.header-banner-field input[type="color"] { width: 72px; padding: 4px; background: #fffdf8; }
.header-banner-field input[type="range"] { display: block; width: 100%; padding: 0; accent-color: var(--wine); background: transparent; }
.header-banner-help { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: 0; line-height: 1.5; }
.header-banner-control-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 18px; }
.header-banner-control-grid .header-banner-field { margin-top: 18px; }
.header-banner-preview-row { min-width: 0; margin-top: 20px; padding: 14px; border: 1px solid var(--line); background: rgba(255,253,248,.72); }
.header-banner-preview-row > span { display: block; margin-bottom: 9px; color: var(--muted); font-size: 12px; font-weight: 800; }
.header-banner-preview { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 58px; overflow: hidden; padding: 6px 10px; border: 1px solid rgba(110,32,41,.12); background: #f7f2e8; font-family: "Source Han Sans SC", "Microsoft YaHei", sans-serif; font-weight: 800; line-height: 1.2; text-align: center; white-space: nowrap; }
.header-banner-editor :disabled { cursor: not-allowed; opacity: .62; }
.header-banner-feedback { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.header-banner-status { flex: 1 1 180px; min-width: 0; min-height: 20px; color: var(--wine); font-size: 13px; font-weight: 800; line-height: 1.5; }
.header-banner-retry { min-height: 44px; padding: 0 14px; white-space: nowrap; }
.header-banner-save { width: 100%; margin-top: 16px; padding: 0 16px; }

@media (max-width: 520px) {
  .header-banner-control-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .header-banner-preview-row { padding: 12px; }
}
