@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&family=Noto+Sans+SC:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: light;
  --canvas: #f4f7f5;
  --surface: #ffffff;
  --surface-soft: #eef5f1;
  --ink: #16231d;
  --muted: #66746d;
  --line: #dce6e0;
  --brand: #087a53;
  --brand-dark: #05613f;
  --brand-soft: #dff4e9;
  --orange: #f18b42;
  --danger: #c3413b;
  --shadow: 0 18px 50px rgba(23, 50, 38, 0.08);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(rgba(8, 122, 83, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(8, 122, 83, 0.035) 1px, transparent 1px),
    var(--canvas);
  background-size: 32px 32px;
  font-family: 'Manrope', 'Noto Sans SC', sans-serif;
  letter-spacing: 0;
}

button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.shell { width: min(1320px, calc(100% - 48px)); margin: 0 auto; padding: 24px 0 72px; }

.site-header { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); font-weight: 800; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 7px; color: #fff; background: var(--brand); }
.service-state { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.service-state i { width: 8px; height: 8px; border-radius: 50%; background: #24ad76; box-shadow: 0 0 0 4px rgba(36, 173, 118, 0.12); }

.hero { max-width: 760px; padding: 76px 0 34px; }
.eyebrow, .section-kicker { margin: 0; color: var(--brand); font-size: 12px; font-weight: 800; letter-spacing: 0; }
.hero h1 { margin: 12px 0; font-size: 62px; line-height: 1.08; letter-spacing: 0; overflow-wrap: anywhere; }
.hero > p:last-child { margin: 0; color: var(--muted); font-size: 17px; line-height: 1.8; }

.query-card, .section-block, .metric {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.query-card { max-width: 100%; padding: 20px; overflow: hidden; border-radius: 8px; }
.query-form { display: grid; grid-template-columns: auto minmax(240px, 1fr) auto 44px; gap: 12px; align-items: center; min-width: 0; }
.query-form > label { padding: 0 8px; font-size: 14px; font-weight: 800; white-space: nowrap; }
.token-field { display: grid; grid-template-columns: 1fr auto; overflow: hidden; min-width: 0; border: 1px solid var(--line); border-radius: 6px; background: #f8faf9; }
.token-field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(8, 122, 83, 0.09); }
input { min-width: 0; height: 48px; padding: 0 15px; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; outline: none; background: #f8faf9; }
.token-field input { border: 0; border-radius: 0; background: transparent; }
input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(8, 122, 83, 0.09); }
.text-button { min-width: 64px; padding: 0 14px; color: var(--brand); border: 0; border-left: 1px solid var(--line); background: transparent; font-weight: 700; }
.primary-button, .redeem-form button, .modal-actions button, .pagination button {
  min-height: 46px;
  padding: 0 22px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  color: #fff;
  background: var(--brand);
  font-weight: 800;
}
.primary-button:hover, .redeem-form button:hover, .modal-actions button:hover { background: var(--brand-dark); }
.icon-button { display: grid; place-items: center; width: 44px; height: 46px; padding: 0; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: var(--surface); font-size: 22px; }
.message { min-height: 20px; margin: 10px 8px -4px; color: var(--muted); font-size: 13px; }
.message[data-type='success'] { color: var(--brand); }
.message[data-type='error'] { color: var(--danger); }

.summary { display: grid; grid-template-columns: 1.25fr repeat(3, 1fr); gap: 14px; margin-top: 18px; }
.metric { min-width: 0; padding: 22px; border-radius: 8px; box-shadow: none; }
.metric span { display: block; margin-bottom: 16px; color: var(--muted); font-size: 13px; }
.metric strong { display: block; overflow: hidden; font-size: 28px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.metric em { display: block; overflow: hidden; margin-top: 8px; color: var(--muted); font-size: 12px; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.metric.identity { color: #fff; border-color: var(--brand); background: var(--brand); }
.metric.identity span, .metric.identity em { color: rgba(255,255,255,.72); }
.metric.identity strong { font-size: 20px; }

.workspace { display: grid; grid-template-columns: minmax(300px, 0.75fr) minmax(600px, 1.7fr); gap: 18px; margin-top: 18px; align-items: start; }
.recharge-column, .records-column { display: grid; gap: 18px; min-width: 0; }
.section-block { min-width: 0; padding: 24px; border-radius: 8px; box-shadow: none; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-head h2 { margin: 5px 0 0; font-size: 20px; }
.section-head > span { color: var(--muted); font-size: 12px; text-align: right; }
.section-head.compact { margin-bottom: 16px; }

.packages { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.package { position: relative; display: grid; gap: 5px; min-height: 94px; padding: 15px; text-align: left; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #f8faf9; }
.package:hover { border-color: #93bbaa; }
.package.active { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.package span { color: var(--muted); font-size: 12px; }
.package strong { font-size: 16px; }
.package em { color: var(--brand); font-size: 11px; font-style: normal; }
.full-button { width: 100%; }
.subtle { margin: 10px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.order-box { display: grid; gap: 8px; margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.order-box div { display: flex; justify-content: space-between; gap: 14px; font-size: 12px; }
.order-box span { color: var(--muted); }
.order-box strong { overflow-wrap: anywhere; text-align: right; }

.redeem-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.redeem-form button { padding: 0 18px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.usage-table { min-width: 1040px; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); background: #f7faf8; font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdfc; }
.source-ip { color: var(--ink); background: transparent; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12px; }
.cache-value { color: #167a55; font-weight: 800; }
.cache-value.is-empty { color: var(--muted); font-weight: 500; }
.order-number { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.status { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 4px; font-weight: 700; }
.status.success { color: var(--brand); background: var(--brand-soft); }
.status.warning { color: #a6551d; background: #fff0e4; }
.empty { margin: 0; padding: 36px 12px; color: var(--muted); text-align: center; }

.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 14px; }
.pagination button { min-height: 34px; padding: 0 14px; }
.pagination button:disabled { cursor: not-allowed; opacity: .38; }
.pagination span { color: var(--muted); font-size: 12px; }

.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(13, 30, 23, .62); cursor: default; }
.modal-card { position: relative; width: min(420px, 100%); padding: 28px; border-radius: 8px; background: var(--surface); box-shadow: 0 30px 90px rgba(0,0,0,.25); text-align: center; }
.modal-card h3 { margin: 8px 0; font-size: 23px; }
.modal-card > p:not(.section-kicker) { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.qr-frame { display: grid; place-items: center; width: 232px; height: 232px; margin: 0 auto 20px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.qr-frame img { width: 210px; height: 210px; object-fit: contain; }
.modal-actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.modal-actions .secondary-button { color: var(--ink); border-color: var(--line); background: #fff; }

.hidden { display: none !important; }

@media (max-width: 980px) {
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { grid-template-columns: 1fr; }
  .recharge-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .shell { width: min(100% - 28px, 1320px); padding-top: 14px; }
  .hero { padding: 48px 0 24px; }
  .hero h1 { max-width: 100%; font-size: 36px; line-height: 1.2; }
  .query-form { grid-template-columns: minmax(0, 1fr) 44px; }
  .query-form > label, .token-field { grid-column: 1 / -1; }
  .query-form > .primary-button { width: 100%; min-width: 0; }
  .summary { grid-template-columns: 1fr; }
  .recharge-column { grid-template-columns: 1fr; }
  .section-head { display: block; }
  .section-head > span { display: block; margin-top: 8px; text-align: left; }
  .packages { grid-template-columns: 1fr 1fr; }
  .section-block { padding: 18px; }
  .redeem-form { grid-template-columns: 1fr; }
  .pagination { justify-content: space-between; }
}

@media (max-width: 420px) {
  .packages { grid-template-columns: 1fr; }
  .site-header { min-height: 40px; }
  .hero h1 { font-size: 32px; }
  .service-state { display: none; }
  .modal-actions { grid-template-columns: 1fr; }
}
