:root {
  color-scheme: light;
  --ink: #18211d;
  --muted: #66716b;
  --line: #dce3df;
  --surface: #ffffff;
  --canvas: #f7f9f8;
  --green: #087c69;
  --green-dark: #07584d;
  --blue: #2d6ca8;
  --orange: #c95b35;
  --red: #b53f3f;
  --shadow: 0 20px 55px rgba(20, 33, 27, .13);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--canvas); line-height: 1.5; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border: 1px solid transparent; border-radius: 6px; font-weight: 750; }
.button svg { width: 17px; height: 17px; }
.button-primary { color: white; background: var(--green); }
.button-primary:hover { background: var(--green-dark); }
.button-quiet { color: var(--ink); background: var(--surface); border-color: #ccd6d1; }
.button-danger { color: white; background: var(--red); }
.icon-button { width: 40px; height: 40px; display: inline-grid; place-items: center; padding: 0; border: 1px solid #d4ddd8; border-radius: 5px; color: var(--ink); background: var(--surface); }
.icon-button:hover { background: #eef3f0; }
.icon-button svg { width: 18px; height: 18px; }
.filter-select { min-height: 40px; padding: 0 34px 0 11px; border: 1px solid #cbd6d0; border-radius: 5px; color: var(--ink); background: white; }
.payment-toolbar { justify-content: flex-start; }
.payment-toolbar .record-count { margin-left: auto; }
.order-id { display: inline-block; max-width: 190px; overflow: hidden; color: #34423b; font-family: Consolas, monospace; font-size: 12px; text-overflow: ellipsis; vertical-align: middle; white-space: nowrap; }

.access-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg, #f8fcfb, #edf5f8 56%, #f3eff9); }
.access-panel { width: min(420px, 100%); display: grid; gap: 18px; padding: 34px; border: 1px solid rgba(199, 214, 207, .9); border-radius: 8px; background: rgba(255, 255, 255, .92); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.access-brand { display: flex; align-items: center; gap: 11px; font-weight: 800; }
.access-brand img { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; }
.access-panel h1 { margin: 8px 0 2px; font-size: 28px; letter-spacing: 0; }
.access-panel label, dialog label { display: grid; gap: 7px; color: #39463f; font-size: 13px; font-weight: 700; }
.access-panel input, dialog input, dialog select, dialog textarea, .editable-table input { width: 100%; min-height: 42px; padding: 0 11px; border: 1px solid #cbd6d0; border-radius: 5px; color: var(--ink); background: white; outline: none; }
.access-panel input:focus, dialog input:focus, dialog select:focus, dialog textarea:focus, .editable-table input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(8, 124, 105, .1); }
.form-error { min-height: 20px; margin: -3px 0; color: var(--red); font-size: 13px; }
.back-link { display: inline-flex; align-items: center; justify-content: center; gap: 7px; color: var(--muted); font-size: 13px; }
.back-link svg { width: 15px; }
.denied-panel { text-align: center; justify-items: center; }
.denied-panel p { margin: 0; color: var(--muted); }
.denied-icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 7px; color: var(--red); background: #fceeee; }
.denied-icon svg { width: 28px; height: 28px; }
.denied-actions { display: flex; gap: 10px; margin-top: 10px; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px 16px; color: #dfe9e4; background: #17231e; }
.sidebar-brand { height: 48px; display: grid; grid-template-columns: 38px 1fr; grid-template-rows: 23px 18px; align-items: center; column-gap: 10px; margin: 0 8px 28px; }
.sidebar-brand img { width: 38px; height: 38px; grid-row: 1 / 3; border-radius: 6px; object-fit: cover; }
.sidebar-brand span { align-self: end; color: white; font-size: 17px; font-weight: 850; }
.sidebar-brand small { align-self: start; color: #90a49a; font-size: 11px; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { width: 100%; min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 13px; border: 0; border-radius: 5px; color: #aebfb6; background: transparent; text-align: left; }
.nav-item svg { width: 18px; height: 18px; }
.nav-item:hover { color: white; background: #22332b; }
.nav-item.active { color: white; background: #0c6c5d; }
.sidebar-footer { margin-top: auto; display: grid; gap: 4px; padding-top: 14px; border-top: 1px solid #2a3a32; }
.sidebar-footer a, .sidebar-footer button { min-height: 40px; display: flex; align-items: center; gap: 11px; padding: 0 13px; border: 0; border-radius: 5px; color: #9fb1a8; background: transparent; font-size: 13px; text-align: left; }
.sidebar-footer a:hover, .sidebar-footer button:hover { color: white; background: #22332b; }
.sidebar-footer svg { width: 17px; height: 17px; }

.admin-main { min-width: 0; }
.admin-header { height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 34px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .92); backdrop-filter: blur(12px); }
.admin-header p { margin: 0 0 2px; color: var(--green); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.admin-header h1 { margin: 0; font-size: 22px; letter-spacing: 0; }
.header-tools { display: flex; align-items: center; gap: 14px; }
.admin-identity { display: grid; text-align: right; }
.admin-identity small { color: var(--muted); font-size: 10px; }
.admin-identity strong { font-size: 13px; }
.content-area { width: min(1440px, 100%); padding: 30px 34px 54px; }
.view { min-width: 0; }

.metric-grid { display: grid; gap: 20px; }
.metric-section { min-width: 0; }
.metric-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.metric-heading > strong { font-size: 13px; }
.metric-heading small { color: var(--muted); font-size: 11px; }
.metric-row { display: grid; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.metric-row-overview { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-row-revenue { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.metric-row article { min-width: 0; min-height: 124px; padding: 20px; border-left: 1px solid var(--line); }
.metric-row article:first-child { border-left: 0; }
.metric-row span, .metric-row small { display: block; color: var(--muted); font-size: 12px; }
.metric-row article > strong { display: block; margin: 11px 0 6px; overflow-wrap: anywhere; font-size: 25px; line-height: 1.1; }
.metric-row article[data-tone="blue"] > strong { color: var(--blue); }
.metric-row article[data-tone="green"] > strong { color: var(--green); }
.metric-row article[data-tone="orange"] > strong { color: var(--orange); }
.metric-row article[data-tone="red"] > strong { color: var(--red); }
.metric-row article[data-tone="pink"] > strong { color: #a33f70; }
.metric-row .metric-primary { background: #f2f7fb; box-shadow: inset 0 3px 0 var(--blue); }
.metric-footnotes { min-height: 42px; display: flex; align-items: center; justify-content: flex-end; gap: 24px; padding: 8px 4px 0; color: var(--muted); font-size: 12px; }
.metric-footnotes strong { color: var(--ink); }
.overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 24px; }
.data-section { padding: 22px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.section-title, .section-intro { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.section-title h2, .section-intro h2 { margin: 0; font-size: 17px; letter-spacing: 0; }
.section-title p, .section-intro p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.text-button { display: inline-flex; align-items: center; gap: 5px; padding: 4px; border: 0; color: var(--green); background: transparent; font-size: 12px; font-weight: 750; }
.text-button svg { width: 14px; }
.compact-list { margin-top: 18px; border-top: 1px solid var(--line); }
.compact-row { min-height: 62px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; border-bottom: 1px solid #edf1ef; }
.compact-row span { min-width: 0; display: grid; }
.compact-row small { color: var(--muted); }
.compact-row > strong { color: var(--blue); font-size: 13px; }
.model-price-row { min-height: 72px; align-items: start; padding-block: 12px; }
.model-price-row > span:first-child small { margin-top: 3px; overflow-wrap: anywhere; line-height: 1.45; }
.model-price-value { max-width: 360px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 3px 10px; color: var(--blue); font-size: 12px; text-align: right; }
.model-price-value b { white-space: nowrap; }
.model-price-value small { width: 100%; }

.toolbar, .section-intro { min-height: 52px; margin-bottom: 18px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.search-box { width: min(420px, 100%); height: 42px; display: grid; grid-template-columns: 36px minmax(0, 1fr) 40px; align-items: center; border: 1px solid #cbd6d0; border-radius: 6px; background: white; }
.search-box > svg { width: 17px; justify-self: center; color: var(--muted); }
.search-box input { min-width: 0; height: 40px; border: 0; outline: 0; }
.search-box .icon-button { width: 38px; height: 38px; border: 0; }
.record-count { color: var(--muted); font-size: 12px; }
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 13px 14px; color: #536059; background: #f0f4f2; border-bottom: 1px solid var(--line); font-size: 11px; text-align: left; white-space: nowrap; }
td { min-height: 56px; padding: 13px 14px; border-bottom: 1px solid #edf1ef; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfc; }
.user-cell { min-width: 180px; display: grid; }
.user-cell small { color: var(--muted); }
.money-positive { color: var(--green); font-weight: 800; }
.money-negative { color: var(--red); font-weight: 800; }
.status-pill { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 4px; color: #256a5a; background: #eaf6f1; font-size: 11px; font-weight: 800; white-space: nowrap; }
.status-pill.warn { color: #9b4f2d; background: #fdf0e9; }
.status-pill.off { color: #6b7470; background: #ecefed; }
.actions-column { text-align: right; }
.row-actions { display: inline-flex; justify-content: flex-end; gap: 5px; white-space: nowrap; }
.row-actions button { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 1px solid #d3dcd7; border-radius: 5px; color: #435149; background: white; }
.row-actions button:hover { color: var(--green); border-color: #a9c8bb; background: #f2f8f5; }
.row-actions svg { width: 16px; height: 16px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 16px; }
.pagination span { min-width: 64px; color: var(--muted); font-size: 12px; text-align: center; }
.pagination .button { min-height: 36px; padding-inline: 12px; font-size: 12px; }
.editable-table input { min-width: 110px; min-height: 36px; }
.pricing-table { min-width: 0; table-layout: fixed; }
.pricing-table th:nth-child(1) { width: 18%; }
.pricing-table th:nth-child(2) { width: 23%; }
.pricing-table th:nth-child(3), .pricing-table th:nth-child(4), .pricing-table th:nth-child(5) { width: 12%; }
.pricing-table th:nth-child(6) { width: 11%; }
.pricing-table th:nth-child(7) { width: 10%; }
.pricing-table .actions-column .button { gap: 5px; padding-inline: 8px; white-space: nowrap; }
.pricing-model-list { min-width: 0; display: flex; flex-wrap: wrap; gap: 5px; }
.pricing-model-list code { max-width: 100%; padding: 3px 6px; overflow-wrap: anywhere; border: 1px solid #dbe5e0; border-radius: 4px; color: #285c50; background: #f3f8f6; font-family: inherit; font-size: 11px; line-height: 1.35; }
.pricing-model-empty, .pricing-readonly-label, .pricing-na { color: var(--muted); font-size: 12px; }
.pricing-readonly-row { background: #fafcfb; }
.pricing-unit-price { color: var(--blue); white-space: nowrap; }
.toggle-field { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.toggle-field input, .check-field input { width: 17px; height: 17px; min-height: 0; accent-color: var(--green); }
.empty-row { padding: 42px !important; color: var(--muted); text-align: center; }
.audit-detail { display: block; max-width: 380px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.catalog-cell { min-width: 240px; display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; gap: 11px; }
.catalog-cover { width: 42px; height: 42px; display: grid; place-items: center; overflow: hidden; border: 1px solid #d4ddd8; border-radius: 6px; color: var(--blue); background: #edf5fb; }
.catalog-cover.mini-app { color: #a33f70; background: #fbf0f6; }
.catalog-cover img { width: 100%; height: 100%; object-fit: cover; }
.catalog-cover svg { width: 19px; height: 19px; }
.catalog-copy { min-width: 0; display: grid; }
.catalog-copy small { max-width: 320px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.content-entry-list { max-height: 250px; margin-top: 20px; overflow: auto; border-block: 1px solid var(--line); }
.content-entry-row { min-height: 58px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 9px 0; border-bottom: 1px solid #edf1ef; }
.content-entry-row:last-child { border-bottom: 0; }
.content-entry-row > span { min-width: 0; display: grid; }
.content-entry-row small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.content-entry-row .button { min-height: 34px; padding-inline: 10px; font-size: 12px; }
.content-entry-row .revoke-button { color: var(--red); }

dialog { width: min(620px, calc(100% - 32px)); padding: 30px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: white; box-shadow: var(--shadow); }
.wide-dialog { width: min(760px, calc(100% - 32px)); }
.usage-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 20px; }
.usage-toolbar .button { min-height: 36px; padding-inline: 12px; font-size: 12px; }
.usage-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 16px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.usage-metrics article { min-width: 0; min-height: 105px; padding: 16px; border-left: 1px solid var(--line); }
.usage-metrics article:nth-child(3n + 1) { border-left: 0; }
.usage-metrics article:nth-child(n + 4) { border-top: 1px solid var(--line); }
.usage-metrics span, .usage-metrics small { display: block; color: var(--muted); font-size: 12px; }
.usage-metrics strong { display: block; margin: 8px 0 4px; overflow-wrap: anywhere; color: var(--green); font-size: 21px; line-height: 1.1; }
.usage-section { margin-top: 18px; padding: 18px; }
.usage-section .section-title { margin-bottom: 14px; }
.usage-section .table-wrap { max-height: 280px; }
dialog::backdrop { background: rgba(13, 23, 18, .55); backdrop-filter: blur(4px); }
.dialog-close { position: absolute; top: 14px; right: 14px; border: 0; }
.dialog-eyebrow { margin: 0 0 6px; color: var(--green); font-size: 11px; font-weight: 800; text-transform: uppercase; }
dialog h2 { margin: 0; font-size: 24px; }
.dialog-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
dialog form { display: grid; gap: 18px; margin-top: 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.full-field { grid-column: 1 / -1; }
dialog textarea { min-height: 84px; padding-block: 10px; resize: vertical; }
dialog label small { color: var(--muted); font-weight: 500; }
.check-field { display: flex; align-items: center; }
.upload-note { min-height: 18px; margin: -8px 0 0; color: var(--muted); font-size: 12px; font-weight: 500; }
.money-field { position: relative; display: block; }
.money-field b { position: absolute; left: 11px; top: 10px; z-index: 1; color: var(--muted); font-weight: 500; }
.money-field input { padding-left: 29px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }
.toast { position: fixed; z-index: 80; left: 50%; bottom: 24px; max-width: min(460px, calc(100% - 32px)); padding: 12px 16px; border-radius: 6px; color: white; background: #18211d; box-shadow: var(--shadow); opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: 180ms ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1050px) {
  .admin-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .sidebar-brand { grid-template-columns: 38px; justify-content: center; margin-inline: 0; }
  .sidebar-brand span, .sidebar-brand small, .nav-item span, .sidebar-footer span { display: none; }
  .nav-item, .sidebar-footer a, .sidebar-footer button { justify-content: center; padding: 0; }
  .metric-row-overview, .metric-row-revenue { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-row-overview article:nth-child(2n + 1), .metric-row-revenue article:nth-child(2n + 1) { border-left: 0; }
  .metric-row-overview article:nth-child(n + 3), .metric-row-revenue article:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .metric-row-revenue article:last-child { grid-column: 1 / -1; }
  .overview-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .admin-shell { display: block; }
  .sidebar { position: sticky; z-index: 20; width: 100%; height: 62px; display: grid; grid-template-columns: 46px minmax(0, 1fr) 46px; padding: 8px; }
  .sidebar-brand { width: 42px; height: 42px; margin: 0; }
  .sidebar-brand img { width: 38px; height: 38px; }
  .sidebar nav { display: flex; min-width: 0; overflow-x: auto; padding-inline: 4px; scrollbar-width: none; -ms-overflow-style: none; }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .nav-item { width: 42px; min-width: 42px; min-height: 42px; }
  .sidebar-footer { display: block; margin: 0; padding: 0; border: 0; }
  .sidebar-footer a { display: none; }
  .sidebar-footer button { width: 42px; height: 42px; }
  .admin-header { height: 70px; padding: 0 16px; }
  .admin-header h1 { font-size: 19px; }
  .admin-identity { display: none; }
  .content-area { padding: 20px 16px 44px; }
  .metric-grid { gap: 16px; }
  .metric-row-overview, .metric-row-revenue { grid-template-columns: 1fr 1fr; }
  .metric-row article { min-height: 112px; padding: 16px; }
  .metric-row article > strong { font-size: 21px; }
  .metric-footnotes { align-items: flex-start; flex-direction: column; gap: 4px; }
  .model-price-row { grid-template-columns: 1fr; gap: 8px; }
  .model-price-value { max-width: none; justify-content: flex-start; text-align: left; }
  .pricing-table { min-width: 1120px; }
  .toolbar, .section-intro { align-items: stretch; flex-direction: column; }
  .search-box { width: 100%; }
  .payment-toolbar .record-count { margin-left: 0; }
  .section-intro .button { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .usage-metrics { grid-template-columns: 1fr 1fr; }
  .usage-metrics article:nth-child(3n + 1) { border-left: 1px solid var(--line); }
  .usage-metrics article:nth-child(2n + 1) { border-left: 0; }
  .usage-metrics article:nth-child(3) { border-top: 1px solid var(--line); }
  .full-field { grid-column: auto; }
  dialog { padding: 26px 20px; }
  .content-entry-row { grid-template-columns: minmax(0, 1fr) auto; }
  .content-entry-row > .status-pill { display: none; }
  .denied-actions { display: grid; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
