/* Portal-only visual system. The public site remains unchanged. */
:root {
  --portal-forest: #252b27;
  --portal-deep: #1b211d;
  --portal-leaf: #617a67;
  --portal-moss: #87988a;
  --portal-sage: #d9e5d5;
  --portal-fog: #eff2ed;
  --portal-paper: rgba(250, 252, 248, .88);
  --portal-paper-solid: #f8faf6;
  --portal-mist: rgba(229, 237, 225, .82);
  --portal-line: rgba(46, 59, 51, .14);
  --portal-muted: #68736c;
  --portal-warm: #9b7658;
  --portal-gold: #c2a45c;
  --portal-sky: #a9c8cf;
  --portal-rose: #c59ca1;
  --portal-display: "Instrument Serif", "Noto Serif SC", Georgia, serif;
}

.app-page {
  min-height: 100svh;
  color: var(--portal-forest);
  background: var(--portal-fog);
}

.app-page,
.app-page * { letter-spacing: 0; }
.app-page ::selection { color: #fff; background: var(--portal-leaf); }
.app-page :focus-visible { outline: 2px solid var(--portal-leaf); outline-offset: 2px; }

.app-backdrop {
  position: fixed;
  z-index: -3;
  inset: 0;
  display: block;
  overflow: hidden;
  background: #798078;
}

.app-backdrop img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
  filter: saturate(.72) contrast(1.05) brightness(.9);
  transform: scale(1.03);
}

.app-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(12, 16, 13, .28), rgba(12, 16, 13, .15) 38%, rgba(12, 16, 13, .36));
}

.app-header {
  top: 12px;
  left: 16px;
  right: 16px;
  height: 62px;
  gap: 18px;
  padding: 8px 9px 8px 11px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  color: #fff;
  background: rgba(21, 25, 22, .72);
  box-shadow: inset 0 1px rgba(255, 255, 255, .1), 0 14px 44px rgba(8, 12, 9, .18);
  backdrop-filter: blur(22px) saturate(.72);
}

.app-header .brand { min-width: 0; }
.app-header .brand-mark {
  width: 42px;
  height: 42px;
  border: 0;
  color: #fff;
  background: rgba(255, 255, 255, .14);
  box-shadow: none;
}
.app-header .brand strong {
  color: #fff;
  font-family: var(--portal-display);
  font-size: 23px;
  font-style: normal;
  font-weight: 400;
}

.header-user {
  gap: 9px;
  padding: 4px 4px 4px 13px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 7px;
  background: rgba(255, 255, 255, .07);
}
.header-user b { color: #fff; font-size: 13px; }
.header-user small { font-size: 12px; }
.app-page .header-user small { color: rgba(255, 255, 255, .68); }
.header-user-home { border-radius: 50%; }
.header-avatar { width: 34px; height: 34px; color: #1c211e; background: #fff; }
.header-user-home:hover .header-avatar { color: #fff; background: var(--portal-leaf); transform: translateY(-1px); }
.header-user .app-icon-button { color: rgba(255, 255, 255, .76); background: transparent; }
.header-user .app-icon-button:hover { color: #fff; background: rgba(255, 255, 255, .12); }
.app-layout {
  grid-template-columns: 228px minmax(0, 1fr);
  gap: 14px;
  padding: 88px 16px 16px;
}

.app-sidebar {
  top: 88px;
  height: calc(100svh - 104px);
  padding: 16px 12px 12px;
  border: 1px solid rgba(255, 255, 255, .17);
  border-radius: 8px;
  color: #fff;
  background: rgba(22, 27, 23, .7);
  box-shadow: inset 0 1px rgba(255, 255, 255, .1), 0 20px 52px rgba(8, 12, 9, .2);
  backdrop-filter: blur(24px) saturate(.72);
}
.app-page .sidebar-label { margin: 8px 11px 12px; color: rgba(255, 255, 255, .46); font-size: 10px; }
.app-page .sidebar-label::after {
  content: "";
  width: 34px;
  height: 2px;
  display: block;
  margin-top: 9px;
  background: var(--portal-gold);
}
.app-nav { gap: 4px; }
.app-nav button,
.app-nav a {
  min-height: 44px;
  gap: 11px;
  padding: 11px 12px;
  border-radius: 6px;
  color: rgba(255, 255, 255, .68);
  font-size: 13px;
  font-weight: 600;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}
.app-nav button:hover,
.app-nav a:hover { color: #fff; background: rgba(255, 255, 255, .1); transform: translateX(2px); }
.app-nav button svg,
.app-nav a svg { color: rgba(255, 255, 255, .48); }
.app-nav button.is-active { position: relative; color: var(--portal-deep); background: rgba(255, 255, 255, .92); box-shadow: inset 3px 0 var(--portal-gold); }
.app-nav button.is-active svg { color: var(--portal-leaf); }
.app-nav button.is-active::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: auto;
  flex: 0 0 6px;
  background: var(--portal-gold);
  transform: rotate(45deg);
}
.app-page .app-sidebar .app-nav button:not(.is-active),
.app-page .app-sidebar .app-nav a { color: rgba(255, 255, 255, .72); }
.app-page .app-sidebar .app-nav button:not(.is-active) svg,
.app-page .app-sidebar .app-nav a svg { color: rgba(255, 255, 255, .5); }

.sidebar-card {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 7px;
  color: #fff;
  background: rgba(255, 255, 255, .08);
}
.app-page .sidebar-card small { color: rgba(255, 255, 255, .58); font-size: 12px; }
.sidebar-card b { margin: 6px 0 14px; font-family: var(--portal-display); font-size: 29px; }
.sidebar-card button { width: 100%; padding: 0; color: #fff; font-size: 12px; }

.app-main {
  min-height: calc(100svh - 104px);
  padding: 38px clamp(22px, 4vw, 58px) 64px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(20, 25, 21, .04) 0, rgba(245, 246, 241, .92) 205px, rgba(247, 248, 244, .97) 480px, rgba(247, 248, 244, .985) 100%);
  box-shadow: inset 0 1px rgba(255, 255, 255, .18), 0 20px 60px rgba(8, 12, 9, .14);
  backdrop-filter: blur(8px) saturate(.86);
}

.view-panel.is-active { animation: portalFadeUp .48s cubic-bezier(.25, .1, .25, 1) both; }
.view-heading { min-height: 112px; align-items: flex-end; margin-bottom: 28px; padding: 0 0 22px; border-bottom: 1px solid rgba(255, 255, 255, .28); }
.view-heading p { margin-bottom: 7px; color: rgba(255, 255, 255, .68); font-size: 11px; font-weight: 800; }
.view-heading h1 {
  color: #fff;
  font-family: var(--portal-display);
  font-size: clamp(40px, 4.2vw, 56px);
  font-weight: 400;
  line-height: .92;
  text-shadow: 0 2px 20px rgba(0, 0, 0, .24);
}
.view-heading h1 em { color: #dce6cf; }
.app-page .view-heading > small { max-width: 420px; color: rgba(255, 255, 255, .82); font-size: 14px; line-height: 1.6; text-shadow: 0 1px 14px rgba(0,0,0,.24); }

.app-button {
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 7px;
  color: #fff;
  background: var(--portal-leaf);
  font-size: 13px;
  font-weight: 700;
  transition: background 160ms ease, transform 160ms ease;
}
.app-button:hover { color: #fff; background: #617b67; transform: translateY(-1px); }
.app-button.secondary { border: 1px solid var(--portal-line); color: var(--portal-forest); background: rgba(255, 255, 255, .62); }
.app-button.secondary:hover { color: var(--portal-forest); background: var(--portal-sage); }
.app-icon-button { border-radius: 7px; color: var(--portal-forest); background: var(--portal-mist); }

.metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; background: transparent; }
.metric-card {
  min-height: 150px;
  padding: 19px;
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  background: var(--portal-paper);
  box-shadow: 0 12px 32px rgba(31, 66, 45, .04);
}
.metric-card span { color: #59675e; font-size: 13px; }
.metric-card span svg { color: var(--portal-leaf); }
.metric-card b { margin: 20px 0 6px; color: var(--portal-forest); font-family: var(--portal-display); font-size: clamp(29px, 3vw, 38px); font-weight: 400; }
.metric-card b,
.sidebar-card b,
.dashboard-facts b,
.wallet-summary b,
.affiliate-stat b,
.invite-card > div b,
.checkin-stats b {
  font-family: var(--portal-body);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.app-page .metric-card small { color: #667269; font-size: 13px; }
.metric-card:first-child { background: rgba(229, 238, 225, .9); }
.metric-card:nth-child(2) { border-color: rgba(168, 120, 81, .2); background: rgba(245, 237, 228, .88); }
.metric-card.token-metric { grid-column: span 2; border-color: rgba(112, 139, 117, .2); color: var(--portal-forest); background: rgba(220, 231, 216, .92); }
.metric-card.token-metric span,
.metric-card.token-metric b,
.metric-card.token-metric small { color: var(--portal-forest); }
.metric-card.token-metric span svg { color: var(--portal-leaf); }

.dashboard-facts { gap: 1px; margin: 10px 0; border: 1px solid var(--portal-line); border-radius: 8px; background: var(--portal-line); overflow: hidden; }
.dashboard-facts > span { min-height: 72px; padding: 14px 16px; background: rgba(239, 244, 236, .9); }
.app-page .dashboard-facts small { color: #667269; font-size: 12px; }
.dashboard-facts b { color: var(--portal-forest); font-size: 14px; }

.dashboard-grid { gap: 10px; margin-bottom: 10px; background: transparent; }
.app-panel,
.key-row,
.wallet-summary article,
.affiliate-grid > article {
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  background: var(--portal-paper);
  box-shadow: 0 12px 34px rgba(31, 66, 45, .04);
}
.app-panel { padding: 20px; }
.panel-head h2,
.table-head h2 { color: var(--portal-forest); font-size: 16px; }
.app-page .panel-head span,
.app-page .panel-head p,
.panel-head button { color: #657168; font-size: 13px; }

.usage-chart { width: 100%; height: 190px; min-height: 190px; display: block; padding: 0; border: 0; }
.usage-chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.trend-grid { stroke: rgba(31, 67, 46, .1); stroke-width: 1; }
.trend-area { fill: url(#trend-fill); }
.trend-line { fill: none; stroke: #466e52; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.trend-point { fill: #f8faf6; stroke: #466e52; stroke-width: 2; transition: r 160ms ease, fill 160ms ease; }
.trend-point:hover { r: 5; fill: var(--portal-sage); }
.chart-days { color: var(--portal-muted); }
.app-page .chart-days { color: #667269; font-size: 10px; }

.distribution-row span i { background: rgba(31, 67, 46, .09); }
.distribution-row span { color: #4f5d54; font-size: 12px; }
.distribution-row span i::after { background: #55785d; }
.distribution-row:nth-child(2) span i::after { background: #9a7356; }
.distribution-row:nth-child(3) span i::after { background: #819a7d; }
.distribution-row:nth-child(4) span i::after { background: #aeb8ad; }

.table-panel { overflow: hidden; }
.data-table { color: var(--portal-forest); font-size: 13px; }
.data-table th { color: #5e6a62; background: rgba(232, 239, 229, .72); font-size: 12px; }
.data-table td { border-color: rgba(31, 67, 46, .08); }
.data-table td.model-name small { color: #667269; font-size: 12px; }
.data-table tbody tr:hover td { background: rgba(203, 220, 197, .2); }
.status-pill { border-radius: 6px; color: var(--portal-forest); background: rgba(203, 220, 197, .58); font-size: 12px; }

.filters-row { gap: 8px; margin-bottom: 12px; }
.app-input,
.app-select,
.field input,
.field textarea,
.field select {
  min-height: 43px;
  border: 1px solid var(--portal-line);
  border-radius: 7px;
  color: var(--portal-forest);
  background: rgba(255, 255, 255, .72);
  box-shadow: none;
}
.app-input:focus,
.app-select:focus,
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: var(--portal-leaf); box-shadow: 0 0 0 3px rgba(85, 120, 93, .12); }
.app-page .field label { color: #56645b; font-size: 12px; }
.field input,
.field textarea,
.field select,
.app-input,
.app-select { font-size: 13px; }

.key-list { gap: 8px; background: transparent; }
.key-rate-note {
  min-height: 62px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin: -8px 0 14px;
  padding: 12px 16px;
  border: 1px solid rgba(148, 116, 45, .2);
  border-left: 3px solid var(--portal-gold);
  border-radius: 7px;
  color: #4f503f;
  background: rgba(244, 239, 220, .9);
  box-shadow: 0 10px 26px rgba(45, 52, 39, .05);
}
.key-rate-note > svg { width: 20px; height: 20px; justify-self: center; color: #8a7138; }
.key-rate-note p { margin: 0; font-size: 13px; line-height: 1.7; }
.key-rate-note strong { color: var(--portal-forest); font-weight: 700; }
.key-row { padding: 15px 16px; }
.key-row:hover { border-color: var(--portal-moss); }
.key-name > i { border-radius: 6px; background: var(--portal-leaf); }
.key-name b { color: var(--portal-forest); }
.switch input:checked + span { background: var(--portal-leaf); }

.wallet-summary,
.affiliate-grid { gap: 10px; background: transparent; }
.wallet-summary article:first-child,
.invite-card { color: var(--portal-forest); background: rgba(224, 233, 220, .92) !important; }
.wallet-summary article:first-child small,
.wallet-summary article:first-child b,
.invite-card small,
.invite-card b,
.invite-card p { color: var(--portal-forest) !important; }
.invite-card .app-icon-button { color: var(--portal-forest); background: var(--portal-sage); }
.affiliate-grid > article:nth-child(2) { background: rgba(235, 241, 232, .92); }
.affiliate-grid > article:nth-child(3) { background: rgba(244, 237, 228, .88); }
.redeem-hero { border: 1px solid rgba(155, 118, 88, .16); border-radius: 8px; color: var(--portal-forest); background: rgba(241, 234, 226, .92); }
.redeem-hero h2 { color: var(--portal-forest); }
.redeem-hero p { color: #657068; font-size: 13px; line-height: 1.6; }
.redeem-hero .app-input { color: var(--portal-forest); background: rgba(255, 255, 255, .74); }
.redeem-hero .app-input::placeholder { color: #727b75; opacity: 1; }
.redeem-hero .app-button { color: var(--portal-forest); background: var(--portal-paper-solid); }

.automatic-checkin { border-radius: 7px; color: var(--portal-forest); background: var(--portal-sage); }
.checkin-overview { gap: 10px; background: transparent; }
.checkin-rules { border-color: rgba(112, 139, 117, .2); color: var(--portal-forest); background: rgba(224, 233, 220, .92); }
.checkin-rules .panel-head p,
.checkin-rules .panel-head > svg { color: var(--portal-leaf); }
.checkin-rules .panel-head h2 { color: var(--portal-forest); }
.rule-list > span { border-color: var(--portal-line); }
.rule-list i { color: #7d8b81; }
.rule-list b { color: var(--portal-forest); font-size: 13px; }
.rule-list small { color: #647067; font-size: 13px; }
.checkin-rules .checkin-milestones span { border-color: var(--portal-line); }
.checkin-rules .checkin-milestones small { color: #647067; }
.checkin-stats { border-color: var(--portal-line); background: var(--portal-line); }
.checkin-stats span,
.checkin-calendar > span { background: rgba(233, 240, 230, .84); }
.checkin-stats b { color: var(--portal-forest); }
.checkin-stats small { color: #647067; font-size: 11px; }
.checkin-stats b { font-size: 15px; }
.checkin-weekdays { color: #647067; font-size: 10px; }
.checkin-calendar > span { font-size: 12px; }
.checkin-milestones b { font-size: 12px; }
.checkin-milestones small { font-size: 11px; }
.checkin-calendar > span { border-radius: 5px; }
.checkin-calendar > span.is-checked { color: #fff; background: var(--portal-leaf); }

.profile-heading { padding-bottom: 20px; border-bottom: 1px solid var(--portal-line); }
.profile-ecosystem {
  position: relative;
  min-height: 190px;
  margin: -4px 0 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .58);
  border-radius: 8px;
  background: url('./assets/portal-field.jpg') center 56% / cover no-repeat;
  box-shadow: inset 0 1px rgba(255,255,255,.46), 0 16px 38px rgba(21, 49, 32, .12);
  isolation: isolate;
}
.profile-ecosystem::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: '';
  background: linear-gradient(180deg, rgba(16, 35, 25, .08), rgba(12, 34, 21, .34));
}
.profile-ecosystem::after {
  position: absolute;
  right: -6%;
  bottom: 22px;
  left: -6%;
  height: 1px;
  content: '';
  background: rgba(255,255,255,.54);
  box-shadow: 0 -36px rgba(255,255,255,.18);
}
.ecosystem-line { position: absolute; border: 1px solid rgba(255,255,255,.4); border-left: 0; border-bottom: 0; border-radius: 50%; }
.ecosystem-line.line-one { right: 8%; bottom: -34px; width: 48%; height: 118px; transform: rotate(-5deg); }
.ecosystem-line.line-two { left: -8%; bottom: -65px; width: 58%; height: 145px; transform: rotate(8deg); }
.ecosystem-flower,
.ecosystem-tractor,
.ecosystem-bug { position: absolute; z-index: 2; display: grid; place-items: center; color: #fff; filter: drop-shadow(0 4px 9px rgba(14, 37, 23, .28)); }
.ecosystem-flower svg { width: 42px; height: 42px; stroke-width: 1.3; }
.ecosystem-flower.flower-one { left: 8%; bottom: 21px; transform-origin: 50% 100%; animation: ecosystemSway 4.8s ease-in-out infinite; }
.ecosystem-flower.flower-two { left: 16%; bottom: 18px; opacity: .74; transform-origin: 50% 100%; animation: ecosystemSway 5.8s ease-in-out -1.5s infinite reverse; }
.ecosystem-flower.flower-two svg { width: 30px; height: 30px; }
.ecosystem-tractor { bottom: 25px; left: -70px; animation: ecosystemDrive 12s linear infinite; }
.ecosystem-tractor svg { width: 58px; height: 58px; stroke-width: 1.25; }
.ecosystem-bug { top: 32px; right: 15%; animation: ecosystemBug 7.5s ease-in-out infinite; }
.ecosystem-bug svg { width: 25px; height: 25px; stroke-width: 1.35; }
.profile-layout { grid-template-columns: minmax(360px, 1.05fr) minmax(340px, .95fr); gap: 10px; background: transparent; }
.profile-layout > .app-panel,
.rank-media-settings { padding: 26px; border: 1px solid var(--portal-line); border-radius: 8px; box-shadow: 0 12px 34px rgba(31, 66, 45, .04); }
.profile-identity { background: var(--portal-paper); box-shadow: inset 0 3px var(--portal-leaf), 0 12px 34px rgba(46, 59, 51, .04); }
.profile-security { border-color: rgba(167, 132, 59, .2) !important; color: var(--portal-forest); background: rgba(241, 238, 224, .9); box-shadow: inset 0 3px var(--portal-gold), 0 12px 34px rgba(46, 59, 51, .04); }
.profile-card-title { margin-bottom: 22px; }
.profile-card-title > span:first-child { border-radius: 7px; color: #fff; background: var(--portal-leaf); }
.profile-card-title p { color: #5f7965; font-size: 10px; }
.profile-card-title h2 { color: var(--portal-forest); font-family: var(--portal-display); font-size: 30px; font-weight: 400; }
.profile-card-title small { color: #647067; font-size: 12px; }
.profile-security .profile-card-title > span:first-child { color: #4c4330; background: #dfd09e; }
.profile-security .profile-card-title p { color: #87713e; }
.profile-security .profile-card-title h2,
.profile-security .field label,
.profile-security .form-feedback { color: var(--portal-forest); }
.profile-security .profile-note,
.profile-note { color: #5f6b63; font-size: 13px; }
.profile-security .field input { border-color: var(--portal-line); background: rgba(255, 255, 255, .78); }
.profile-security .app-button { color: #fff; background: var(--portal-leaf); }
.profile-security .app-button.secondary { color: var(--portal-forest); border-color: var(--portal-line); background: rgba(255, 255, 255, .68); }
.profile-security .app-button.secondary:hover { color: var(--portal-forest); background: var(--portal-sage); }
.rank-media-settings { margin-top: 10px; background: rgba(230, 238, 239, .9); box-shadow: inset 0 3px var(--portal-sky), 0 12px 34px rgba(46, 59, 51, .04); }
.rank-media-settings .profile-card-title > span:first-child { color: #344f55; background: #cce0e3; }
.rank-media-settings .profile-card-title p { color: #557b83; }
.rank-media-preview { min-height: 260px; border: 1px dashed rgba(31, 67, 46, .25); border-radius: 8px; color: var(--portal-muted); background: rgba(248, 250, 246, .58); }
.rank-media-controls small { color: #5f6b63; font-size: 13px; line-height: 1.65; }
.state-message,
.table-empty { color: #657168; font-size: 13px; }

.wallet-summary small,
.affiliate-grid small,
.invite-card p,
.affiliate-stat span { font-size: 13px; }

.app-modal { border: 1px solid var(--portal-line); border-radius: 8px; background: var(--portal-paper-solid); box-shadow: 0 28px 90px rgba(16, 41, 29, .22); }
.app-modal-head h2 { color: var(--portal-forest); font-family: var(--portal-display); }
.ccs-modal { width: min(570px, calc(100vw - 28px)); }
.ccs-modal .modal-description { margin: 5px 0 18px; color: #59645d; font-size: 13px; line-height: 1.65; }
.ccs-client-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border: 1px solid var(--portal-line); border-radius: 8px; background: #edf1eb; }
.ccs-client-tabs button { min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 9px; border: 0; border-radius: 6px; color: #69736c; background: transparent; font-size: 13px; font-weight: 700; }
.ccs-client-tabs button.is-active { color: var(--portal-forest); background: #fff; box-shadow: 0 5px 16px rgba(28, 36, 30, .09); }
.ccs-client-tabs button:disabled { opacity: .4; cursor: not-allowed; }
.ccs-client-tabs svg { width: 17px; }
.ccs-model-field { display: grid; gap: 7px; margin-top: 18px; }
.ccs-model-field label { color: var(--portal-forest); font-size: 12px; font-weight: 700; }
.ccs-model-field select { width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--portal-line); border-radius: 7px; color: var(--portal-forest); background: #fff; font-size: 13px; }
.ccs-model-field small { min-height: 18px; color: #626d65; font-size: 11px; line-height: 1.55; }
.ccs-import-preview { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 17px 0; padding: 13px 14px; border-left: 3px solid var(--portal-gold); color: #5e6961; background: #eef2ec; }
.ccs-import-preview span { font-size: 10px; font-weight: 700; text-transform: uppercase; }
.ccs-import-preview b { color: var(--portal-forest); font-size: 13px; }
.ccs-import-preview code { grid-column: 1 / -1; overflow: hidden; color: #68736b; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.ccs-confirm { width: 100%; }

.view-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.console-filter-grid {
  padding: 12px;
  border: 1px solid var(--portal-line);
  border-radius: 7px;
  background: rgba(246, 248, 243, .72);
}
.console-filter-grid .app-input,
.console-filter-grid .app-select { flex: 1 1 150px; min-width: 0; }
.key-filters .app-input { flex-basis: 280px; }
.usage-filters .usage-request-filter { flex-basis: 260px; }
.wallet-filters { margin: 0; border-width: 0 0 1px; border-radius: 0; }
.wallet-filters .app-input:first-child { flex-basis: 260px; }
.pagination-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.pagination-row span { min-width: 160px; color: #657168; font-size: 12px; text-align: center; }
.pagination-row .app-button { min-height: 36px; }

.key-row {
  grid-template-columns: minmax(220px, 1.35fr) minmax(120px, .7fr) minmax(125px, .72fr) minmax(125px, .72fr) 38px minmax(250px, auto);
}
.key-name small:last-child { white-space: normal; line-height: 1.45; }
.key-actions { justify-content: flex-end; flex-wrap: wrap; }
.key-actions .app-icon-button { flex: 0 0 34px; }
.key-actions .app-icon-button.danger { color: #984b4b; background: rgba(148, 65, 65, .09); }
.key-actions .app-icon-button.danger:hover { color: #fff; background: #984b4b; }
.system-lock { padding: 7px 9px; border-radius: 6px; color: #677269; background: var(--portal-sage); font-size: 10px; white-space: nowrap; }
.key-editor-modal { width: min(640px, calc(100vw - 28px)); }
.setup-fields { display: grid; gap: 8px; }
.setup-fields > label { margin-top: 8px; color: #56645b; font-size: 12px; font-weight: 700; }
.setup-fields > div { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) 34px; align-items: center; gap: 8px; padding: 10px 10px 10px 13px; border: 1px solid var(--portal-line); border-radius: 7px; background: #fff; }
.setup-fields code { overflow: hidden; color: var(--portal-forest); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.affiliate-bind { display: flex; gap: 7px; margin-top: 12px; }
.affiliate-bind .app-input { min-width: 0; flex: 1; background: rgba(255, 255, 255, .72); }
.affiliate-bound { margin-top: 12px; padding: 10px 12px; border-left: 3px solid var(--portal-gold); color: #5e6961; background: rgba(255, 255, 255, .48); font-size: 11px; line-height: 1.6; }

.toast { border-radius: 7px; color: #fff; background: var(--portal-leaf); }
.toast.is-error { background: #815f54; }

@keyframes portalFadeUp {
  from { opacity: 0; transform: translateY(14px); filter: blur(4px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}
@keyframes ecosystemSway {
  0%, 100% { transform: rotate(-5deg) translateY(0); }
  50% { transform: rotate(7deg) translateY(-3px); }
}
@keyframes ecosystemDrive {
  0% { left: -70px; transform: translateY(0); }
  48% { transform: translateY(-2px); }
  100% { left: calc(100% + 70px); transform: translateY(0); }
}
@keyframes ecosystemBug {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-8deg); opacity: .62; }
  28% { transform: translate3d(-34px, 18px, 0) rotate(12deg); opacity: 1; }
  62% { transform: translate3d(18px, 44px, 0) rotate(-18deg); opacity: .78; }
}

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-card.token-metric { grid-column: auto; }
  .profile-layout { grid-template-columns: 1fr; }
}

@media (max-width: 1000px) {
  .app-layout { grid-template-columns: 72px minmax(0, 1fr); }
  .app-sidebar { padding: 12px 8px; }
  .app-nav button { justify-content: center; padding: 12px; }
  .app-nav button:hover { transform: none; }
  .app-nav span,
  .sidebar-label,
  .sidebar-card { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .app-backdrop img { object-position: 58% center; }
  .app-header { top: 8px; left: 8px; right: 8px; height: 58px; padding: 7px 8px; }
  .app-header .brand strong,
  .header-user span { display: none; }
  .app-layout { display: block; padding: 74px 8px 8px; }
  .app-main {
    min-height: calc(100svh - 82px);
    padding: 26px 12px 92px;
    background: linear-gradient(180deg, rgba(20, 25, 21, .04) 0, rgba(245, 246, 241, .94) 185px, rgba(247, 248, 244, .985) 420px, rgba(247, 248, 244, .995) 100%);
  }
  .app-sidebar { position: fixed; z-index: 30; top: auto; left: 8px; right: 8px; bottom: 8px; height: 62px; padding: 6px; border-radius: 8px; }
  .app-nav { height: 100%; flex-direction: row; gap: 2px; }
  .app-nav button { flex: 1 1 0; min-width: 0; min-height: 48px; padding: 0; border-radius: 6px; }
  .app-nav button:nth-child(n+6) { display: flex; }
  .view-heading { align-items: flex-start; flex-direction: column; gap: 13px; margin-bottom: 20px; }
  .view-heading h1 { font-size: 42px; }
  .view-heading > small { text-align: left; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 7px; }
  .metric-card,
  .metric-card.token-metric { min-height: 132px; grid-column: auto; padding: 14px; }
  .metric-card b { font-size: 27px; }
  .dashboard-facts { grid-template-columns: 1fr 1fr; }
  .dashboard-facts > span { min-height: 66px; align-items: flex-start; flex-direction: column; }
  .usage-chart { height: 165px; min-height: 165px; }
  .profile-layout > .app-panel,
  .rank-media-settings { padding: 18px; }
  .profile-card-title { grid-template-columns: 42px minmax(0, 1fr); }
  .profile-card-title > .status-pill { grid-column: 1 / -1; justify-self: start; }
  .rank-media-editor,
  .security-code-row { grid-template-columns: 1fr; }
  .wallet-summary,
  .affiliate-grid,
  .checkin-overview { grid-template-columns: 1fr; }
  .filters-row { align-items: stretch; flex-direction: column; }
  .view-actions { width: 100%; justify-content: flex-start; }
  .console-filter-grid .app-input,
  .console-filter-grid .app-select { flex-basis: auto; width: 100%; }
  .pagination-row { flex-wrap: wrap; gap: 7px; }
  .pagination-row span { order: -1; width: 100%; }
  .key-row { grid-template-columns: 1fr; align-items: stretch; }
  .key-actions { justify-content: flex-start; }
  .affiliate-bind { flex-direction: column; }
  .data-table { min-width: 620px; }
  .table-panel { overflow-x: auto; }
  .profile-ecosystem { min-height: 160px; }
  .key-rate-note { grid-template-columns: 26px minmax(0, 1fr); gap: 8px; margin-top: 0; padding: 11px 12px; }
  .key-rate-note p { font-size: 12px; }
  .ecosystem-flower.flower-one { left: 6%; }
  .ecosystem-flower.flower-two { left: 20%; }
}

@media (prefers-reduced-motion: reduce) {
  .view-panel.is-active { animation: none; }
  .ecosystem-flower,
  .ecosystem-tractor,
  .ecosystem-bug { animation: none; }
  .ecosystem-tractor { left: 52%; }
  .app-page *,
  .app-page *::before,
  .app-page *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
