:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17211b;
  background: #f4f6f4;
  font-synthesis: none;
  --surface: #ffffff;
  --surface-2: #f0f3f0;
  --line: #d9dfda;
  --muted: #66736a;
  --text: #17211b;
  --green: #18794e;
  --green-dark: #11633f;
  --red: #b42318;
  --amber: #a15c08;
  --shadow: 0 14px 42px rgba(24, 42, 30, .09);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f4f6f4; color: var(--text); }
button, input, select { font: inherit; letter-spacing: 0; }
button { min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; }
button:hover { border-color: #aeb9b1; background: var(--surface-2); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { color: #fff; border-color: var(--green); background: var(--green); font-weight: 650; }
button.primary:hover { border-color: var(--green-dark); background: var(--green-dark); }
button.danger { color: var(--red); }
button.wide { width: 100%; }
button.text-button { margin-top: 8px; border-color: transparent; color: var(--green); background: transparent; font-size: 12px; }
.icon-button { width: 38px; min-width: 38px; padding: 0; display: inline-grid; place-items: center; font-size: 18px; }
.topbar { height: 58px; padding: 0 24px; display: flex; align-items: center; gap: 28px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.95); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand img { width: 30px; height: 30px; object-fit: contain; }
.brand span { font-size: 15px; }
.brand strong { color: var(--green); }
nav { display: flex; align-self: stretch; align-items: stretch; gap: 4px; }
nav a { min-width: 68px; padding: 0 14px; display: grid; place-items: center; color: var(--muted); text-decoration: none; font-size: 14px; white-space: nowrap; border-bottom: 2px solid transparent; }
nav a:hover, nav a.active { color: var(--text); background: #f7f9f7; }
nav a.active { border-bottom-color: var(--green); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.health { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.health i { width: 8px; height: 8px; border-radius: 50%; background: #9ca69f; }
.health.online i { background: #20a464; box-shadow: 0 0 0 3px #dff4e8; }
.health.offline i { background: var(--red); }
main { min-height: calc(100vh - 58px); }
.auth-shell { min-height: calc(100vh - 58px); display: grid; grid-template-columns: minmax(0, 1fr); place-content: center; padding: 32px 20px; background: linear-gradient(180deg, #eef5f0 0, #f4f6f4 45%); }
.auth-panel { width: 100%; max-width: 390px; justify-self: center; padding: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.auth-logo { width: 48px; height: 48px; margin-bottom: 24px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 9px; font-size: 26px; line-height: 1.2; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 19px; letter-spacing: 0; }
h3 { margin-bottom: 4px; font-size: 15px; letter-spacing: 0; }
.eyebrow { margin-bottom: 7px; color: var(--green); font-size: 10px; line-height: 1; font-weight: 800; letter-spacing: 1.4px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
label { display: grid; gap: 7px; margin: 16px 0; color: #354039; font-size: 13px; font-weight: 600; }
input, select { width: 100%; height: 40px; padding: 0 11px; border: 1px solid #cbd3cd; border-radius: 6px; background: var(--surface); color: var(--text); outline: none; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(24,121,78,.12); }
.form-error { min-height: 18px; margin: 6px 0; color: var(--red); font-size: 12px; }
.workspace { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 30px 0 56px; }
.page-heading { min-height: 62px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.page-heading p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.toolbar { display: flex; align-items: center; gap: 8px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.metric { min-height: 116px; padding: 22px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 12px; font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; }
.section { margin-top: 24px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-title h2 { font-size: 15px; }
.table-shell { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { height: 42px; padding: 0 14px; text-align: left; color: var(--muted); background: #f7f9f7; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 700; white-space: nowrap; }
td { height: 53px; padding: 8px 14px; border-bottom: 1px solid #e8ece9; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.numeric { font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.actions button { min-height: 32px; padding: 0 9px; font-size: 12px; }
.badge { display: inline-flex; align-items: center; min-height: 23px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 700; color: #236342; background: #e1f3e8; }
.badge.revoked, .badge.disabled, .badge.consumed { color: #8d221b; background: #fbe8e6; }
.badge.permanent { color: #65531d; background: #f8efcc; }
.feature-list { display: flex; flex-wrap: wrap; gap: 5px; max-width: 360px; }
.feature { padding: 3px 6px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: 10px; }
.empty { min-height: 180px; display: grid; place-items: center; color: var(--muted); border: 1px dashed #cbd3cd; border-radius: 8px; background: rgba(255,255,255,.55); }
dialog { width: min(92vw, 590px); max-height: 90vh; overflow-y: auto; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); box-shadow: 0 24px 80px rgba(17,31,22,.24); }
dialog::backdrop { background: rgba(20,29,23,.46); }
dialog form, dialog > div, dialog > p, dialog > .secret-row { margin-left: 24px; margin-right: 24px; }
dialog form { margin-top: 0; margin-bottom: 0; padding: 24px 0; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
fieldset { margin: 18px 0; padding: 14px; border: 1px solid var(--line); border-radius: 6px; }
legend { padding: 0 6px; color: var(--muted); font-size: 12px; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.check { margin: 0; display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--green); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.secret-row { display: flex; align-items: center; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: #f7f9f7; }
.secret-row code { flex: 1; overflow-wrap: anywhere; color: #174b32; }
#key-dialog { padding: 24px 0; }
.portal-switch { color: var(--green); font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.settings-band { display: grid; grid-template-columns: repeat(4, minmax(110px, 1fr)) auto auto; gap: 12px; align-items: end; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.settings-band label { margin: 0; }
.settings-band .check { align-self: center; }
.operation-grid { margin-top: 24px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--line); }
.profile-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.pool-list { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.pool-list > div { min-height: 42px; padding: 7px 12px; display: grid; grid-template-columns: minmax(140px, 1fr) auto 70px 58px; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); font-size: 12px; }
.pool-list > div:last-child { border-bottom: 0; }
.pool-list small { color: var(--amber); }
.draw-prize-list { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.draw-prize-list > div { min-height: 42px; padding: 7px 12px; display: grid; grid-template-columns: minmax(180px, 1fr) minmax(120px, 1fr) 72px; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); font-size: 12px; }
.draw-prize-list > div:last-child { border-bottom: 0; }
.draw-prize-list > div > :last-child { text-align: right; font-variant-numeric: tabular-nums; }
.lottery-workspace { display: grid; gap: 16px; }
.lottery-status-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.lottery-status-strip > div { min-width: 0; min-height: 86px; padding: 16px; border-right: 1px solid var(--line); }
.lottery-status-strip > div:last-child { border-right: 0; }
.lottery-status-strip span { display: block; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.lottery-status-strip strong { display: block; margin-top: 8px; font-size: 22px; font-variant-numeric: tabular-nums; }
.lottery-status-strip strong small { color: var(--muted); font-size: 12px; font-weight: 600; }
.lottery-bonus-strip { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
.lottery-bonus-strip > span { color: var(--text); font-weight: 700; }
.lottery-bonus-strip b { color: var(--green); font-variant-numeric: tabular-nums; }
.lottery-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.lottery-column { display: grid; gap: 16px; align-content: start; }
.lottery-panel { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.lottery-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.lottery-panel-heading .eyebrow { margin-bottom: 5px; }
.lottery-panel-heading h2 { font-size: 16px; }
.panel-count { flex: 0 0 auto; padding-top: 2px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.draw-result { min-height: 84px; display: grid; align-content: center; gap: 4px; padding: 14px; border: 1px dashed #bec9c0; background: #fafcf9; text-align: center; }
.draw-result span, .draw-result small { color: var(--muted); font-size: 12px; }
.draw-result strong { color: var(--text); font-size: 17px; }
.draw-result.has-result { border-style: solid; border-color: #9fd1b2; background: #edf8f0; }
.lottery-action { width: 100%; margin-top: 12px; }
.lottery-subheading { display: flex; justify-content: space-between; gap: 12px; margin: 18px 0 7px; color: var(--text); font-size: 12px; font-weight: 700; }
.lottery-subheading small { color: var(--muted); font-weight: 500; }
.lottery-list { overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.lottery-row { min-height: 46px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 7px 10px; border-bottom: 1px solid var(--line); font-size: 12px; }
.lottery-row:last-child { border-bottom: 0; }
.lottery-row span, .activity-row span { min-width: 0; display: grid; gap: 2px; }
.lottery-row strong, .activity-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lottery-row small, .activity-row small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.lottery-row b { color: var(--green); font-size: 12px; font-variant-numeric: tabular-nums; }
.forge-row b { min-width: 58px; text-align: right; }
.forge-costs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 10px; border: 1px solid var(--line); background: var(--surface-2); }
.forge-costs span { padding: 9px 10px; color: var(--muted); font-size: 12px; }
.forge-costs span + span { border-left: 1px solid var(--line); }
.forge-costs b { color: var(--text); font-variant-numeric: tabular-nums; }
.lottery-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.lottery-input-row input, .lottery-input-row select { min-width: 0; }
.field-note { display: block; min-height: 16px; margin-top: 7px; color: var(--muted); font-size: 11px; }
.exchange-preview { min-height: 40px; padding: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: 12px; }
.synth-detail { margin: 10px 0; color: var(--muted); font-size: 12px; }
.synthesis-list { max-height: 238px; overflow-y: auto; border: 1px solid var(--line); }
.synthesis-list > label { margin: 0; min-height: 48px; display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-weight: 500; }
.synthesis-list > label:last-child { border-bottom: 0; }
.synthesis-list input { width: 16px; height: 16px; accent-color: var(--green); }
.synthesis-list span { min-width: 0; display: grid; gap: 2px; }
.synthesis-list small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.activity-empty { min-height: 54px; display: grid; place-items: center; padding: 10px; color: var(--muted); font-size: 12px; text-align: center; }
.lottery-history-section { padding-top: 4px; }
.lottery-history-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.lottery-history-grid details { min-width: 0; border: 1px solid var(--line); background: var(--surface); }
.lottery-history-grid summary { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px; cursor: pointer; font-size: 13px; font-weight: 700; }
.lottery-history-grid summary span { color: var(--muted); font-size: 11px; font-weight: 500; }
.activity-list { border-top: 1px solid var(--line); }
.activity-row { min-height: 52px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 12px; }
.activity-row:last-child { border-bottom: 0; }
.activity-row b { color: var(--muted); font-size: 11px; font-weight: 600; text-align: right; }
#issued-key { white-space: pre-wrap; }
.operation { min-height: 190px; padding: 22px; background: var(--surface); }
.operation h2 { font-size: 16px; }
.operation p { min-height: 36px; color: var(--muted); font-size: 12px; }
.inline-controls { display: flex; gap: 8px; align-items: center; }
.inline-controls select, .inline-controls input { min-width: 0; flex: 1; }
#synth-licenses { margin: 14px 0; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: min(390px, calc(100vw - 40px)); padding: 12px 15px; border-radius: 6px; color: #fff; background: #26342b; box-shadow: var(--shadow); font-size: 13px; z-index: 30; }
@media (max-width: 780px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .brand span { display: none; }
  nav { overflow-x: auto; }
  nav a { min-width: 58px; padding: 0 9px; }
  .health { display: none; }
  .workspace { width: min(100% - 24px, 1180px); padding-top: 22px; }
  .page-heading { min-height: 0; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .form-grid, .check-grid, .operation-grid, .settings-band, .profile-layout { grid-template-columns: 1fr; }
  .pool-list > div { grid-template-columns: minmax(120px, 1fr) auto; }
  .pool-list > div > :nth-child(3), .pool-list > div > :nth-child(4) { text-align: right; }
  .draw-prize-list > div { grid-template-columns: minmax(130px, 1fr) auto; }
  .draw-prize-list > div > :nth-child(2) { display: none; }
  .lottery-status-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lottery-status-strip > div { min-height: 76px; border-bottom: 1px solid var(--line); }
  .lottery-status-strip > div:nth-child(2n) { border-right: 0; }
  .lottery-status-strip > div:last-child { grid-column: 1 / -1; border-bottom: 0; }
  .lottery-columns, .lottery-history-grid { grid-template-columns: 1fr; }
  .lottery-panel { padding: 15px; }
  .lottery-input-row { grid-template-columns: 1fr; }
  .lottery-input-row button { width: 100%; }
  .lottery-bonus-strip { gap: 6px 12px; }
  .operation p { min-height: 0; }
  .inline-controls { flex-wrap: wrap; }
  .inline-controls select, .inline-controls input { flex-basis: 100%; }
  td, th { padding-left: 10px; padding-right: 10px; }
}
@media (prefers-color-scheme: dark) {
  :root { --surface: #151a17; --surface-2: #1d2420; --line: #303a33; --muted: #96a29a; --text: #edf2ee; --green: #35a873; --green-dark: #278b5e; --shadow: 0 16px 48px rgba(0,0,0,.3); }
  body { background: #101411; }
  .topbar { background: rgba(21,26,23,.96); }
  .auth-shell { background: #101411; }
  nav a:hover, nav a.active, th, .secret-row { background: #191f1b; }
  td { border-bottom-color: #29312c; }
  input, select { border-color: #3a453e; }
  .badge { color: #79d9a8; background: #183927; }
  .badge.revoked { color: #f2a19a; background: #44201d; }
  .badge.permanent { color: #e6ce79; background: #3d351b; }
  .secret-row code { color: #80d8aa; }
  .empty { background: rgba(21,26,23,.5); }
}
