:root {
  --bg: #f4f0e7;
  --paper: #fffdf8;
  --paper-soft: #faf7ef;
  --ink: #173047;
  --muted: #71808b;
  --line: #e6dfd1;
  --green: #438b61;
  --green-soft: #deeedf;
  --blue: #477ed9;
  --blue-soft: #dce8fb;
  --orange: #c98243;
  --orange-soft: #fae9d8;
  --red: #c15c58;
  --shadow: 0 16px 40px rgba(45, 59, 67, .07);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; letter-spacing: .01em; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(30px, 4vw, 48px); line-height: 1; letter-spacing: -.055em; }
h2 { font-size: 21px; line-height: 1.15; letter-spacing: -.035em; }
.app-shell { min-height: 100vh; }
.topbar { height: 74px; border-bottom: 1px solid rgba(223, 216, 201, .9); display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(20px, 5vw, 64px); background: rgba(255,253,248,.52); }
.brand { display: inline-flex; align-items: center; gap: 11px; }
.brand-mark { width: 29px; height: 22px; position: relative; display: inline-block; }
.brand-mark i { position: absolute; width: 16px; height: 16px; border-radius: 5px 10px 10px 5px; transform: rotate(-12deg); }
.brand-mark i:first-child { background: linear-gradient(135deg, var(--green), #70b887); left: 1px; top: 2px; }
.brand-mark i:last-child { background: rgba(71,126,217,.34); left: 12px; top: 5px; }
.brand strong { display: block; font-size: 18px; letter-spacing: -.04em; }
.brand small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.status { color: var(--muted); font-size: 11px; display: inline-flex; align-items: center; gap: 7px; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(67,139,97,.13); }
.text-button { border: 0; background: transparent; color: var(--green); font-weight: 700; font-size: 12px; padding: 7px; }
.page-shell { width: min(1420px, calc(100% - 48px)); margin: 0 auto; padding: 44px 0 72px; }
.panel { background: var(--paper); border: 1px solid rgba(231,224,210,.82); border-radius: var(--radius-xl); box-shadow: var(--shadow); }
.panel.pad { padding: 26px; }
.eyebrow { color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.muted { color: var(--muted); }
.small-copy { font-size: 12px; line-height: 1.55; margin-top: 9px; }
.button { border: 1px solid var(--line); border-radius: 11px; padding: 10px 15px; background: var(--paper); color: var(--ink); font-size: 12px; display: inline-flex; justify-content: center; align-items: center; gap: 7px; transition: .18s ease; }
.button:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(40,60,70,.08); }
.button.primary { background: var(--green); border-color: var(--green); color: white; }
.button.primary:hover { background: #377951; }
.button.secondary { background: transparent; }
.button.danger { color: var(--red); border-color: #f0d5d3; background: #fff8f7; }
.button.small { padding: 7px 10px; font-size: 11px; border-radius: 9px; }
.icon-button { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); color: var(--muted); font-size: 20px; line-height: 1; }

.toast { position: fixed; z-index: 20; right: 22px; top: 88px; max-width: min(360px, calc(100vw - 44px)); padding: 12px 15px; border: 1px solid #cce1cf; border-radius: 11px; background: #f2faf0; color: #356849; box-shadow: var(--shadow); font-size: 12px; opacity: 0; transform: translateY(-8px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { color: #8c413f; border-color: #f0d5d3; background: #fff7f6; }
.toast.info { color: #3764ac; border-color: #cbdaf2; background: #f3f7ff; }

.auth-shell { min-height: min(630px, calc(100vh - 170px)); display: grid; grid-template-columns: minmax(0, 1fr) minmax(350px, 470px); align-items: center; gap: clamp(42px, 9vw, 150px); max-width: 1120px; margin: 0 auto; }
.intro-copy { max-width: 610px; }
.intro-copy h1 { margin-top: 14px; font-size: clamp(42px, 7vw, 78px); }
.intro-copy h1 em { color: var(--green); font-style: normal; }
.intro-copy > p:last-child { color: var(--muted); font-size: 14px; line-height: 1.8; max-width: 480px; margin-top: 23px; }
.auth-card { padding: 28px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--paper-soft); margin-bottom: 26px; }
.admin-only .auth-tabs { grid-template-columns: 1fr; }
.tab-button { border: 0; background: transparent; border-radius: 9px; color: var(--muted); padding: 10px; font-size: 12px; }
.tab-button.active { background: var(--paper); color: var(--green); font-weight: 800; box-shadow: 0 3px 9px rgba(45,59,67,.07); }
.auth-pane h2 { margin-bottom: 8px; }
.auth-pane > .muted { font-size: 12px; }
.stack-form, .settings-form { display: grid; gap: 14px; margin-top: 22px; }
label { display: grid; gap: 6px; color: var(--ink); font-size: 11px; font-weight: 700; }
label input, label select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #fffefa; color: var(--ink); outline: none; font-size: 13px; font-weight: 500; }
label input:focus, label select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(67,139,97,.1); }
.optional { color: var(--muted); font-size: 10px; font-weight: 500; }
.demo-hint { display: grid; grid-template-columns: auto auto; gap: 5px 10px; margin-top: 20px; padding: 13px; border: 1px dashed #c7d8ca; border-radius: 11px; background: #f4faf1; font-size: 10px; color: var(--muted); }
.demo-hint code { color: var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.demo-hint small { grid-column: 1 / -1; line-height: 1.45; }
.demo-hint.warning { border-color: #e9cfb8; background: #fff9f2; }
.form-error { min-height: 18px; color: var(--red); font-size: 11px; line-height: 1.45; margin-top: 9px; }

.workspace-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 25px; margin-bottom: 28px; }
.workspace-head h1 { margin-top: 9px; }
.workspace-head .muted { font-size: 13px; margin-top: 11px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.state-card { padding: 22px; color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 10px; }
.spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid #cfe2d2; border-top-color: var(--green); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hero { padding: 29px 31px 24px; margin-bottom: 18px; overflow: hidden; }
.hero-top { display: flex; justify-content: space-between; gap: 28px; }
.member-identity { display: flex; align-items: center; gap: 11px; }
.member-identity strong { display: block; font-size: 15px; }
.member-identity small { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.avatar { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: white; background: linear-gradient(145deg,#66ad7b,#3b8159); font-weight: 800; }
.hero-label { color: var(--muted); font-size: 12px; margin-top: 29px; }
.hero-number { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; }
.hero-number strong { color: var(--green); font-size: clamp(43px, 6vw, 66px); line-height: .9; letter-spacing: -.07em; }
.hero-number span { color: var(--muted); font-size: 14px; }
.hero-note { color: var(--muted); font-size: 12px; margin-top: 13px; }
.hero-note b { color: var(--ink); }
.period-card { min-width: 190px; align-self: flex-start; padding: 15px 16px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper-soft); }
.period-card span, .period-card small { display: block; color: var(--muted); font-size: 10px; }
.period-card strong { display: block; font-size: 13px; margin: 8px 0 10px; }
.quota-track { height: 15px; overflow: hidden; background: #e8efe7; border-radius: 999px; margin-top: 27px; }
.quota-track span { display: block; height: 100%; min-width: 0; max-width: 100%; border-radius: inherit; background: linear-gradient(90deg,#91c5a7,#5da877); transition: width .35s ease; }
.track-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; margin-top: 8px; }
.notice { display: flex; align-items: flex-start; gap: 11px; padding: 14px 17px; margin-bottom: 25px; border-radius: var(--radius-md); background: linear-gradient(100deg,#f0f8ec,#fbfcf6); border-color: #cde1d0; color: #426b51; box-shadow: none; }
.notice-icon { width: 23px; height: 23px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; background: var(--green); color: white; font-weight: 800; font-size: 12px; }
.notice strong { color: #2f6646; font-size: 12px; }
.notice p { font-size: 11px; line-height: 1.55; margin-top: 3px; }
.section-block { margin-bottom: 25px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 15px; margin: 0 2px 13px; }
.section-heading h2 { margin-top: 5px; }
.section-heading > .muted { font-size: 11px; }
.model-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.model-card { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--paper); box-shadow: var(--shadow); }
.model-card.sol { border-top: 3px solid var(--green); }
.model-card.terra { border-top: 3px solid var(--blue); }
.model-card.luna { border-top: 3px solid var(--orange); }
.model-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.model-head strong { font-size: 15px; }
.model-head span { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10px; }
.model-kpi { display: flex; align-items: baseline; gap: 6px; margin-top: 21px; }
.model-kpi strong { font-size: 27px; letter-spacing: -.05em; }
.model-kpi span { color: var(--muted); font-size: 10px; }
.model-meta { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--line); }
.model-meta span, .model-meta b { display: block; }
.model-meta span { color: var(--muted); font-size: 10px; }
.model-meta b { font-size: 13px; margin-top: 4px; }
.model-note { color: var(--muted); font-size: 10px; line-height: 1.45; margin-top: 14px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 15px; }
.metric-card { padding: 20px; }
.metric-card > span { display: block; color: var(--muted); font-size: 11px; }
.metric-card strong { display: block; font-size: 28px; letter-spacing: -.05em; margin-top: 13px; }
.metric-card small { display: block; color: var(--muted); font-size: 10px; line-height: 1.4; margin-top: 8px; }
.reconcile-note { display: flex; justify-content: space-between; gap: 22px; padding: 22px 25px; margin-top: 25px; box-shadow: none; }
.reconcile-note h2 { margin-top: 6px; }
.reconcile-note p { max-width: 660px; align-self: center; color: var(--muted); font-size: 12px; line-height: 1.6; }
.modal-card { position: fixed; z-index: 30; left: 50%; top: 50%; width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; padding: 26px; margin: 0; transform: translate(-50%, -50%); box-shadow: 0 0 0 100vmax rgba(23,48,71,.24), var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; }

.admin-tabs { display: flex; gap: 7px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.admin-tab { border: 0; background: transparent; color: var(--muted); border-bottom: 3px solid transparent; padding: 11px 14px; font-size: 12px; }
.admin-tab.active { color: var(--green); border-bottom-color: var(--green); font-weight: 800; }
.admin-flow { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; padding: 12px 16px; margin: -4px 0 20px; color: var(--muted); box-shadow: none; font-size: 11px; }
.admin-flow strong { color: var(--ink); margin-right: 4px; }
.admin-flow b { color: var(--green); font-size: 14px; }
.admin-layout { display: grid; grid-template-columns: minmax(300px, .9fr) minmax(420px, 1.1fr); gap: 16px; }
.group-list, .admin-members, .audit-list { display: grid; gap: 9px; margin-top: 18px; }
.group-item { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; padding: 0; text-align: left; background: var(--paper); transition: .16s; }
.group-item:hover, .group-item.selected { border-color: var(--green); box-shadow: 0 0 0 3px rgba(67,139,97,.1); }
.group-select { width: 100%; border: 0; padding: 14px 14px 50px; text-align: left; background: transparent; color: inherit; }
.group-copy { position: absolute; right: 13px; bottom: 11px; }
.group-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.group-item strong { font-size: 13px; }
.group-item small { display: block; color: var(--muted); font-size: 10px; margin-top: 4px; }
.group-code { display: block; color: var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; font-weight: 800; letter-spacing: .08em; margin-top: 5px; }
.group-item-meta { display: flex; flex-wrap: wrap; gap: 7px 15px; color: var(--muted); font-size: 10px; margin-top: 14px; }
.group-item-meta b { color: var(--ink); }
.pill { display: inline-flex; align-items: center; padding: 4px 7px; border-radius: 999px; font-size: 9px; font-weight: 800; }
.pill.green { color: #2d754b; background: var(--green-soft); }
.pill.orange { color: #9b5a27; background: var(--orange-soft); }
.member-row { display: grid; grid-template-columns: 1fr auto; gap: 13px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.member-row:last-child { border-bottom: 0; }
.member-row-head { display: flex; align-items: center; gap: 9px; }
.member-row-head strong { font-size: 13px; }
.member-row-head small { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; }
.member-row .avatar { width: 31px; height: 31px; border-radius: 9px; font-size: 11px; }
.member-usage { color: var(--muted); font-size: 10px; margin-top: 8px; }
.allocation-editor { display: flex; align-items: center; gap: 8px; }
.allocation-editor input { width: 70px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }
.allocation-editor span { color: var(--muted); font-size: 10px; }
.allocation-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 17px; }
.settings-layout { grid-template-columns: minmax(330px, 1fr) minmax(300px, .8fr); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.check-row { display: flex; align-items: center; grid-template-columns: none; gap: 8px; font-weight: 600; }
.check-row input { width: 15px; height: 15px; accent-color: var(--green); }
.binding-state { padding: 12px; margin-top: 21px; border: 1px dashed #c7d8ca; border-radius: 10px; background: #f4faf1; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10px; line-height: 1.6; overflow-wrap: anywhere; }
.code-lifecycle { padding-top: 20px; margin-top: 22px; border-top: 1px solid var(--line); }
.lifecycle-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.lifecycle-head h3 { font-size: 15px; margin-top: 5px; }
.code-state { display: inline-flex; align-items: center; padding: 5px 8px; border-radius: 999px; background: var(--green-soft); color: #2d754b; font-size: 10px; font-weight: 800; }
.code-state.revoked, .code-state.expired { background: var(--orange-soft); color: #9b5a27; }
.current-code { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 15px; margin-top: 15px; border: 1px solid #c9dec9; border-radius: 11px; background: #f4faf1; }
.current-code span { display: block; color: var(--muted); font-size: 10px; }
.current-code code { display: block; color: var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 18px; font-weight: 800; letter-spacing: .12em; margin-top: 6px; overflow-wrap: anywhere; }
.compact-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.sync-grid { display: grid; grid-template-columns: .8fr 1.2fr; gap: 16px; }
.sync-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 21px; }
.sync-result { min-height: 20px; color: var(--green); font-size: 11px; line-height: 1.5; margin-top: 15px; }
.audit-row { padding: 12px; border: 1px solid #f0d5d3; border-radius: 10px; background: #fff8f7; }
.audit-row strong { color: #8c413f; font-size: 11px; }
.audit-row small { display: block; color: var(--muted); font-size: 10px; line-height: 1.5; margin-top: 5px; overflow-wrap: anywhere; }
.new-code-result { padding: 15px; margin-top: 18px; border: 1px dashed #b9d4bd; border-radius: 11px; background: #f1faef; }
.new-code-result strong { display: block; color: var(--green); font-size: 11px; }
.new-code-result code { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 20px; letter-spacing: .12em; margin-top: 8px; }
.new-code-result small { display: block; color: var(--muted); font-size: 10px; line-height: 1.45; margin-top: 7px; }

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; max-width: 560px; min-height: auto; gap: 35px; padding: 40px 0; }
  .intro-copy { text-align: center; }
  .intro-copy > p:last-child { margin-left: auto; margin-right: auto; }
  .admin-layout, .sync-grid, .settings-layout { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 650px) {
  .page-shell { width: min(100% - 28px, 520px); padding-top: 28px; }
  .topbar { padding: 0 16px; }
  .status { display: none; }
  .workspace-head { align-items: flex-start; flex-direction: column; gap: 16px; }
  .head-actions { justify-content: flex-start; }
  .hero { padding: 23px 20px 20px; }
  .hero-top { flex-direction: column; gap: 24px; }
  .period-card { min-width: 0; }
  .model-grid, .summary-grid { grid-template-columns: 1fr; }
  .reconcile-note { flex-direction: column; gap: 13px; }
  .panel.pad { padding: 20px; }
  .admin-tabs { overflow-x: auto; }
  .admin-tab { white-space: nowrap; }
  .member-row { grid-template-columns: 1fr; }
  .allocation-editor { justify-content: flex-start; }
  .form-row { grid-template-columns: 1fr; }
  .intro-copy h1 { font-size: 49px; }
}
