/* 0 Card Console UI v3 */
:root {
  --canvas: #f3f0e8;
  --paper: #fffdf8;
  --paper-soft: #f8f6ef;
  --ink: #17231d;
  --muted: #748078;
  --line: #dcded5;
  --forest: #122a22;
  --forest-2: #1a382d;
  --forest-3: #24493b;
  --acid: #d6f56f;
  --orange: #f36a3d;
  --orange-deep: #d95128;
  --green: #2e8b65;
  --red: #cf4444;
  --blue: #337a9d;
  --shadow: 0 18px 55px rgba(29, 42, 34, 0.09);
  --shadow-soft: 0 8px 24px rgba(29, 42, 34, 0.06);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --font-sans: "Avenir Next", "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SFMono-Regular", "Roboto Mono", "Cascadia Code", monospace;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(214, 245, 111, 0.2), transparent 26rem),
    radial-gradient(circle at 94% 88%, rgba(243, 106, 61, 0.1), transparent 34rem),
    var(--canvas);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.32;
  background-image:
    linear-gradient(rgba(23, 35, 29, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 35, 29, 0.035) 1px, transparent 1px);
  background-size: 32px 32px;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
}

button,
.copyable {
  -webkit-tap-highlight-color: transparent;
}

::selection {
  color: var(--forest);
  background: var(--acid);
}

.hidden {
  display: none !important;
}

.mono {
  font-family: var(--font-mono) !important;
  font-variant-numeric: tabular-nums;
}

/* Front */
.front-shell {
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
  gap: 18px;
  width: min(1720px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px;
}

.front-panel {
  position: sticky;
  top: 18px;
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 36px);
  min-height: 680px;
  padding: 30px;
  overflow: hidden;
  color: #f8fbf5;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(145deg, rgba(214, 245, 111, 0.08), transparent 38%),
    var(--forest);
  box-shadow: 0 28px 65px rgba(16, 39, 31, 0.19);
  animation: uiRise 0.5s ease both;
}

.front-panel::before {
  position: absolute;
  top: -80px;
  right: -85px;
  width: 220px;
  height: 220px;
  content: "";
  border: 42px solid rgba(214, 245, 111, 0.08);
  border-radius: 50%;
}

.front-panel::after {
  position: absolute;
  right: 26px;
  bottom: 94px;
  width: 46px;
  height: 8px;
  content: "";
  border-radius: 999px;
  background: var(--orange);
  box-shadow: -58px 0 0 var(--acid);
}

.front-panel .logo {
  position: relative;
  z-index: 1;
  display: block;
  margin-bottom: 34px;
}

.front-panel .logo::before {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 12px;
  padding: 0 9px;
  content: "CARD ACCESS";
  color: var(--forest);
  border-radius: 999px;
  background: var(--acid);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.front-panel .logo-title {
  margin: 0;
  color: #fffef9;
  font-size: clamp(26px, 2vw, 34px);
  font-weight: 760;
  letter-spacing: -0.04em;
}

.front-panel .logo::after {
  display: block;
  margin-top: 7px;
  content: "选择渠道，输入通用卡密，即刻获取卡片";
  color: rgba(239, 247, 241, 0.56);
  font-size: 12px;
}

.front-form {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  gap: 14px;
}

.label,
.admin-label {
  display: block;
  margin-bottom: 8px;
  color: inherit;
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.front-panel .label {
  color: rgba(244, 250, 246, 0.62);
}

.channel-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  height: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.channel-pill,
.front-channel-option {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  color: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 13px;
  outline: 0;
  background: rgba(255, 255, 255, 0.045);
  box-shadow: none;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  gap: 9px;
  transition: transform 0.18s ease, border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.front-channel-option:hover:not(:disabled) {
  transform: translateY(-2px);
  color: #fff;
  border-color: rgba(214, 245, 111, 0.45);
  background: rgba(255, 255, 255, 0.075);
}

.front-channel-option.selected {
  color: var(--forest);
  border-color: var(--acid);
  background: var(--acid);
  box-shadow: 0 10px 24px rgba(214, 245, 111, 0.12);
}

.front-channel-option:disabled {
  cursor: not-allowed;
  opacity: 0.36;
}

.dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(243, 106, 61, 0.12);
}

.front-channel-option.selected .dot {
  background: var(--forest);
  box-shadow: 0 0 0 4px rgba(18, 42, 34, 0.12);
}

.front-channel-stock {
  margin-left: auto;
  padding: 3px 6px;
  color: inherit;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
}

.front-channel-option.selected .front-channel-stock {
  background: rgba(18, 42, 34, 0.1);
}

.front-textarea {
  width: 100%;
  min-height: 210px;
  flex: 1;
  resize: none;
  padding: 17px 18px;
  color: #f8fcf8;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  outline: 0;
  background: rgba(0, 0, 0, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.8;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.front-textarea::placeholder {
  color: rgba(236, 244, 239, 0.28);
}

.front-textarea:focus {
  border-color: rgba(214, 245, 111, 0.62);
  background: rgba(0, 0, 0, 0.22);
  box-shadow: 0 0 0 4px rgba(214, 245, 111, 0.07);
}

.front-help {
  color: rgba(238, 246, 241, 0.46);
  font-size: 11px;
}

.front-msg,
.admin-msg,
.auth-msg {
  min-height: 18px;
  color: var(--orange);
  font-size: 12px;
  font-weight: 650;
}

.primary-action {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 58px;
  padding: 0 20px;
  cursor: pointer;
  color: #fff;
  border-radius: 14px;
  background: var(--orange);
  box-shadow: 0 14px 30px rgba(243, 106, 61, 0.2);
  font-size: 14px;
  font-weight: 780;
  letter-spacing: 0.02em;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.primary-action::after {
  content: "↗";
  font-size: 20px;
  font-weight: 500;
}

.primary-action:hover:not(:disabled) {
  transform: translateY(-2px);
  background: #ff7648;
  box-shadow: 0 18px 35px rgba(243, 106, 61, 0.28);
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.76;
}

.primary-action.loading::before {
  width: 15px;
  height: 15px;
  content: "";
  border: 2px solid rgba(255, 255, 255, 0.38);
  border-top-color: #fff;
  border-radius: 50%;
  animation: uiSpin 0.7s linear infinite;
}

.primary-action.loading::after {
  content: "";
}

.footer-note {
  position: relative;
  z-index: 1;
  margin-top: 24px;
  color: rgba(240, 248, 243, 0.35);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
}

.front-result {
  display: grid;
  min-width: 0;
  min-height: calc(100dvh - 36px);
  border: 1px solid rgba(23, 35, 29, 0.08);
  border-radius: var(--radius-xl);
  background: rgba(255, 253, 248, 0.55);
  box-shadow: var(--shadow-soft);
  animation: uiRise 0.55s 0.06s ease both;
}

.empty-state {
  display: flex;
  align-items: center;
  align-self: center;
  justify-content: center;
  flex-direction: column;
  width: min(520px, calc(100% - 40px));
  min-height: 360px;
  margin: auto;
  text-align: center;
  border: 1px dashed #c9cec3;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.34);
}

.empty-card-icon {
  position: relative;
  width: 76px;
  height: 50px;
  margin-bottom: 26px;
  border: 2px solid var(--forest);
  border-radius: 12px;
  transform: rotate(-6deg);
}

.empty-card-icon::before {
  position: absolute;
  top: 11px;
  left: -2px;
  width: calc(100% + 4px);
  height: 8px;
  content: "";
  background: var(--acid);
  border-top: 2px solid var(--forest);
  border-bottom: 2px solid var(--forest);
}

.empty-card-icon::after {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 13px;
  height: 8px;
  content: "";
  border-radius: 3px;
  background: var(--orange);
}

.empty-title {
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 19px;
  font-weight: 760;
  letter-spacing: -0.02em;
}

.empty-copy {
  color: var(--muted);
  font-size: 12px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 14px;
  min-width: 0;
  padding: 18px;
}

.result-grid > .wide,
.result-grid > .result-pager {
  grid-column: 1 / -1;
}

.detail-panel {
  position: relative;
  min-width: 0;
  padding: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-soft);
}

.detail-panel::before {
  position: absolute;
  top: 0;
  left: 22px;
  width: 38px;
  height: 4px;
  content: "";
  border-radius: 0 0 4px 4px;
  background: var(--orange);
}

.detail-panel:nth-of-type(2)::before {
  background: var(--green);
}

.panel-head,
.list-head,
.modal-head,
.stats-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-head {
  min-height: 42px;
  margin-bottom: 8px;
}

.panel-title,
.list-title {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 760;
  letter-spacing: -0.025em;
}

.copy-btn,
.soft-btn,
.danger-btn,
.white-btn,
.logout,
.stats-tab,
.history-page-btn,
.page-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 720;
  transition: transform 0.16s ease, color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.copy-btn,
.soft-btn,
.history-page-btn,
.page-chip {
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--paper-soft);
}

.copy-btn:hover,
.soft-btn:hover,
.history-page-btn:hover,
.page-chip:hover {
  transform: translateY(-1px);
  border-color: #b8c0b6;
  background: #fff;
}

.white-btn {
  min-height: 46px;
  color: #fff;
  background: var(--forest);
  box-shadow: 0 8px 18px rgba(18, 42, 34, 0.14);
}

.white-btn:hover {
  transform: translateY(-1px);
  background: var(--forest-2);
}

.danger-btn {
  color: #fff;
  background: var(--red);
}

.danger-btn:hover {
  transform: translateY(-1px);
  background: #b73535;
}

.compact-btn {
  min-height: 34px;
  padding: 0 11px;
}

.kv-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  align-items: center;
  min-height: 46px;
  border-bottom: 1px solid #e8e9e3;
}

.kv-row:last-child {
  border-bottom: 0;
}

.kv-label {
  color: var(--muted);
  font-size: 12px;
}

.kv-value {
  overflow: hidden;
  color: var(--ink);
  text-align: right;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.copyable {
  cursor: pointer;
}

.copyable:hover .kv-value,
.copyable:hover {
  color: var(--green);
}

.result-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px;
}

.result-pager-label,
.history-page-meta {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.redeem-history-panel {
  width: 100%;
  overflow-x: auto;
}

.redeem-history-head,
.redeem-history-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.45fr) 100px 80px minmax(150px, 1fr) minmax(160px, 1fr);
  align-items: center;
  min-width: 770px;
  gap: 14px;
}

.redeem-history-head {
  min-height: 38px;
  padding: 0 14px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.redeem-history-list {
  display: grid;
  gap: 7px;
  padding-top: 10px;
}

.redeem-history-row {
  min-height: 48px;
  padding: 0 14px;
  color: #4f5d54;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--paper-soft);
  font-size: 11px;
}

.redeem-history-row:hover {
  color: var(--ink);
  border-color: #d8ddd4;
  background: #fff;
}

.redeem-history-pager,
.record-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  padding-top: 16px;
}

.history-page-btn,
.page-chip {
  min-width: 34px;
  min-height: 34px;
  padding: 0 9px;
}

.history-page-btn.active,
.page-chip.active {
  color: var(--forest);
  border-color: var(--acid);
  background: var(--acid);
}

.tx-empty,
.admin-empty {
  display: grid;
  min-height: 130px;
  place-items: center;
  color: var(--muted);
  border: 1px dashed #cdd2c9;
  border-radius: 14px;
  background: rgba(248, 246, 239, 0.55);
  font-size: 12px;
}

/* Admin shell */
.admin-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  gap: 18px;
  min-height: 100dvh;
  padding: 18px;
}

.sidebar {
  position: sticky;
  top: 18px;
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 36px);
  overflow: hidden;
  color: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  background:
    radial-gradient(circle at 20% 4%, rgba(214, 245, 111, 0.12), transparent 13rem),
    var(--forest);
  box-shadow: 0 24px 54px rgba(18, 42, 34, 0.18);
  animation: uiRise 0.45s ease both;
}

.sidebar-head {
  padding: 26px 22px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mark {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  color: var(--forest);
  border: 0;
  border-radius: 13px 13px 13px 4px;
  background: var(--acid);
  box-shadow: none;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 900;
}

.logo-mark::before,
.logo-mark::after {
  display: none;
}

.sidebar .logo-title {
  margin: 0;
  color: #fff;
  font-size: 18px;
  font-weight: 760;
  letter-spacing: -0.025em;
}

.logo-subtitle {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
  padding: 18px 12px;
  overflow-y: auto;
}

.nav-btn {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.58);
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  font-size: 13px;
  font-weight: 660;
  text-align: left;
  gap: 11px;
  transition: color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.nav-btn:hover {
  transform: translateX(2px);
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.nav-btn.active {
  color: var(--forest);
  background: var(--acid);
  box-shadow: 0 10px 20px rgba(214, 245, 111, 0.12);
}

.nav-icon {
  display: inline-grid;
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 15px;
}

.sidebar-foot {
  display: grid;
  gap: 10px;
  padding: 16px;
  color: rgba(255, 255, 255, 0.46);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 11px;
}

.logout {
  justify-content: flex-start;
  width: 100%;
  color: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.045);
}

.logout:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.admin-main {
  min-width: 0;
  padding: 4px 0;
  animation: uiRise 0.5s 0.04s ease both;
}

.admin-view {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.admin-panel,
.stats-titlebar,
.stats-card,
.stats-chart-card {
  min-width: 0;
  padding: 22px;
  border: 1px solid rgba(23, 35, 29, 0.1);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-soft);
}

.admin-panel.tight {
  padding: 22px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
  align-items: end;
  gap: 12px;
}

.form-grid.template {
  grid-template-columns: 0.8fr 1.3fr 1fr;
  margin-top: 18px;
}

.form-grid.template-small {
  grid-template-columns: repeat(4, minmax(120px, 1fr)) auto;
  margin-top: 12px;
}

.split-panel {
  display: grid;
  grid-template-columns: minmax(190px, 0.65fr) minmax(280px, 1.35fr) auto;
  align-items: end;
  gap: 12px;
  margin-top: 18px;
}

.admin-label {
  color: #657168;
}

.admin-input,
.admin-select,
.mini-select,
.record-search,
.stats-date-input,
.admin-textarea {
  width: 100%;
  color: var(--ink);
  border: 1px solid #d9ddd4;
  border-radius: 11px;
  outline: 0;
  background: var(--paper-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  font-size: 13px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.admin-input,
.admin-select,
.record-search,
.stats-date-input {
  height: 46px;
  padding: 0 13px;
}

.mini-select {
  width: auto;
  max-width: 180px;
  height: 36px;
  padding: 0 10px;
  font-size: 11px;
}

.admin-textarea {
  min-height: 190px;
  padding: 14px;
  resize: vertical;
  font-family: var(--font-mono);
  line-height: 1.7;
}

.admin-input:focus,
.admin-select:focus,
.mini-select:focus,
.record-search:focus,
.stats-date-input:focus,
.admin-textarea:focus {
  border-color: var(--green);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(46, 139, 101, 0.09);
}

.admin-input::placeholder,
.admin-textarea::placeholder,
.record-search::placeholder {
  color: #a7aea8;
}

.subcopy {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.list-head {
  min-height: 44px;
  margin-bottom: 14px;
}

.count-badge,
.amount-pill,
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  color: var(--forest);
  border-radius: 999px;
  background: var(--acid);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
}

.tag {
  color: #5d6961;
  background: #eaede6;
}

.tag.green {
  color: #176246;
  background: #dff2e8;
}

.amount-pill {
  color: #9b3d21;
  background: #fde4d9;
}

.admin-list,
.pickup-code-list {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.admin-row,
.template-row,
.record-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  min-height: 66px;
  padding: 13px 15px;
  color: #4a574f;
  border: 1px solid #e0e2db;
  border-radius: 14px;
  background: var(--paper-soft);
  gap: 14px;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.admin-row:hover,
.template-row:hover,
.record-card:hover {
  transform: translateY(-1px);
  border-color: #cbd1c7;
  background: #fff;
  box-shadow: 0 8px 18px rgba(30, 44, 35, 0.05);
}

.row-title {
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.row-sub {
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  font-size: 11px;
  white-space: nowrap;
}

.list-actions,
.channel-actions,
.record-tools,
.code-tool-strip {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 7px;
}

.code-tool-strip {
  margin-bottom: 10px;
}

.inventory-box {
  min-height: 46px;
  padding: 12px 13px;
  color: #536159;
  border: 1px solid #d9ddd4;
  border-radius: 11px;
  background: var(--paper-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
}

.record-titlebar {
  flex-wrap: wrap;
}

.record-summary {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.record-code-pill {
  max-width: 280px;
  padding: 7px 10px;
  overflow: hidden;
  color: #5e6b62;
  border-radius: 8px;
  background: #e9ece6;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
  font-size: 10px;
  white-space: nowrap;
}

.record-arrow {
  color: var(--orange);
}

.record-card-number {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 760;
  letter-spacing: 0.025em;
}

.record-meta {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
  gap: 8px;
}

.record-status {
  color: var(--green);
  font-size: 11px;
  font-weight: 720;
}

.record-status.expired {
  color: var(--red);
}

.record-search {
  width: min(300px, 100%);
}

.page-size-chip {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

/* Analytics */
.stats-shell {
  display: grid;
  gap: 16px;
}

.stats-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.stats-tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.stats-tab {
  min-height: 34px;
  color: var(--muted);
  border: 1px solid transparent;
  background: transparent;
}

.stats-tab:hover {
  color: var(--ink);
  background: var(--paper-soft);
}

.stats-tab.active {
  color: #fff;
  background: var(--forest);
}

.stats-date-input {
  width: 140px;
  height: 34px;
  font-size: 11px;
}

.stats-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 16px;
  min-width: 0;
}

.stats-card {
  align-self: stretch;
  background: var(--forest);
  color: #fff;
}

.stats-card .record-meta {
  color: rgba(255, 255, 255, 0.58);
}

.stats-total {
  margin: 24px 0 4px;
  color: var(--acid);
  font-family: var(--font-mono);
  font-size: 48px;
  font-weight: 850;
  letter-spacing: -0.07em;
}

.stats-range-copy {
  color: rgba(255, 255, 255, 0.42);
  font-family: var(--font-mono);
  font-size: 10px;
}

.channel-summary {
  display: grid;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.channel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgba(255, 255, 255, 0.67);
  font-size: 11px;
}

.channel-row span,
.stats-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.channel-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.stats-chart-card {
  overflow: hidden;
}

.stats-chart-head {
  margin-bottom: 12px;
}

.stats-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 10px;
  gap: 12px;
}

.stats-chart-wrap {
  width: 100%;
  min-height: 480px;
  overflow: hidden;
  border: 1px solid #e6e7e1;
  border-radius: 14px;
  background:
    linear-gradient(rgba(23, 35, 29, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 35, 29, 0.025) 1px, transparent 1px),
    #fcfbf7;
  background-size: 30px 30px;
}

.stats-chart {
  display: block;
  width: 100%;
  height: 480px;
}

/* Modal, auth and pickup */
.modal-backdrop,
.auth-mask {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(11, 25, 20, 0.64);
  backdrop-filter: blur(12px);
  overscroll-behavior: contain;
}

.admin-modal,
.auth-box {
  width: min(560px, 100%);
  max-height: calc(100dvh - 40px);
  padding: 24px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 34px 90px rgba(10, 26, 20, 0.3);
  animation: uiRise 0.25s ease both;
}

.modal-head {
  margin-bottom: 18px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.modal-body,
.auth-form {
  display: grid;
  gap: 12px;
}

.inline-copy-box {
  padding: 14px;
  color: var(--ink);
  border: 1px solid #d7ddd3;
  border-radius: 12px;
  background: var(--paper-soft);
}

.auth-mask {
  background:
    radial-gradient(circle at 15% 12%, rgba(214, 245, 111, 0.17), transparent 24rem),
    radial-gradient(circle at 86% 90%, rgba(243, 106, 61, 0.2), transparent 26rem),
    var(--forest);
}

.auth-box {
  width: min(420px, 100%);
  padding: 34px;
}

.auth-box h2 {
  margin: 0 0 24px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 780;
  letter-spacing: -0.04em;
}

.auth-box h2::before {
  display: block;
  width: 38px;
  height: 5px;
  margin-bottom: 16px;
  content: "";
  border-radius: 999px;
  background: var(--orange);
}

.pickup-page {
  min-height: 100dvh;
  padding: 30px;
}

.pickup-card {
  width: min(860px, 100%);
  margin: 0 auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.copy-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2000;
  padding: 11px 15px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 11px;
  opacity: 0;
  background: var(--forest);
  box-shadow: 0 14px 34px rgba(18, 42, 34, 0.25);
  font-size: 12px;
  font-weight: 700;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.copy-toast.show {
  opacity: 1;
  transform: translateY(0);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(61, 78, 67, 0.25);
  background-clip: padding-box;
}

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

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

@media (max-width: 1180px) {
  .front-shell {
    grid-template-columns: 360px minmax(0, 1fr);
  }

  .front-panel {
    padding: 24px;
  }

  .admin-shell {
    grid-template-columns: 215px minmax(0, 1fr);
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .form-grid .white-btn {
    width: max-content;
  }

  .form-grid.template-small {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .stats-layout {
    grid-template-columns: 210px minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .front-shell {
    display: block;
    padding: 12px;
  }

  .front-panel {
    position: relative;
    top: 0;
    width: 100%;
    height: auto;
    min-height: 660px;
  }

  .front-result {
    min-height: 560px;
    margin-top: 12px;
  }

  .admin-shell {
    display: block;
    padding: 12px;
  }

  .sidebar {
    position: relative;
    top: 0;
    width: 100%;
    height: auto;
    margin-bottom: 12px;
  }

  .sidebar-head {
    padding: 18px;
  }

  .nav {
    flex-direction: row;
    padding: 10px;
    overflow-x: auto;
  }

  .nav-btn {
    flex: 0 0 auto;
    width: auto;
    padding: 0 13px;
  }

  .nav-btn:hover {
    transform: translateY(-1px);
  }

  .sidebar-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
  }

  .logout {
    width: auto;
  }

  .admin-main {
    padding: 0;
  }

  .split-panel,
  .stats-layout {
    grid-template-columns: 1fr;
  }

  .stats-card {
    min-height: 220px;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 13px;
  }

  .front-panel {
    min-height: 610px;
    padding: 22px 18px;
    border-radius: 22px;
  }

  .front-panel .logo {
    margin-bottom: 24px;
  }

  .channel-box,
  .result-grid,
  .form-grid,
  .form-grid.template,
  .form-grid.template-small {
    grid-template-columns: 1fr;
  }

  .front-result {
    min-height: 500px;
    border-radius: 22px;
  }

  .result-grid {
    padding: 10px;
  }

  .detail-panel,
  .admin-panel,
  .stats-titlebar,
  .stats-card,
  .stats-chart-card {
    padding: 17px;
    border-radius: 16px;
  }

  .panel-head,
  .list-head,
  .stats-titlebar,
  .stats-chart-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-row,
  .template-row,
  .record-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .list-actions,
  .channel-actions,
  .record-tools {
    justify-content: flex-start;
    width: 100%;
  }

  .mini-select {
    width: 100%;
    max-width: none;
  }

  .stats-tabs {
    width: 100%;
  }

  .stats-chart-wrap,
  .stats-chart {
    min-height: 360px;
    height: 360px;
  }

  .empty-state {
    min-height: 320px;
  }

  .auth-box {
    padding: 25px 20px;
  }

  .pickup-page {
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
