:root {
  color-scheme: dark;
  --bg: #070a12;
  --bg-top: #111a2a;
  --surface: #111827;
  --surface-2: #0d1422;
  --surface-3: #132238;
  --text: #eef4ff;
  --muted: #9aa8bd;
  --muted-2: #6f7f95;
  --line: rgba(148, 163, 184, 0.2);
  --line-strong: rgba(148, 163, 184, 0.34);
  --accent: #19c6a3;
  --accent-dark: #79f2dc;
  --accent-2: #38bdf8;
  --accent-3: #a78bfa;
  --amber: #fbbf24;
  --danger: #fb7185;
  --ok: #34d399;
  --ink: #f8fafc;
  --shadow: 0 22px 52px rgba(0, 0, 0, 0.38);
  --shadow-soft: 0 12px 28px rgba(0, 0, 0, 0.3);
  --focus: 0 0 0 3px rgba(56, 189, 248, 0.22);
  --radius: 8px;
  --tap: 48px;
}

:root[data-theme="kitty"] {
  color-scheme: light;
  --bg: #fff0f8;
  --bg-top: #ffd1e8;
  --surface: #fff9fd;
  --surface-2: #ffe7f3;
  --surface-3: #ffc6df;
  --text: #36142c;
  --muted: #9a4775;
  --muted-2: #c15f94;
  --line: rgba(244, 114, 182, 0.34);
  --line-strong: rgba(219, 39, 119, 0.46);
  --accent: #ff4fa3;
  --accent-dark: #db2777;
  --accent-2: #ff9bd0;
  --accent-3: #ffd43b;
  --amber: #d97706;
  --danger: #e11d48;
  --ok: #059669;
  --ink: #4a1738;
  --shadow: 0 18px 42px rgba(219, 39, 119, 0.2);
  --shadow-soft: 0 10px 24px rgba(219, 39, 119, 0.16);
  --focus: 0 0 0 3px rgba(255, 79, 163, 0.26);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 0, rgba(25, 198, 163, 0.16) 0, rgba(25, 198, 163, 0) 34%),
    radial-gradient(circle at 88% 12%, rgba(56, 189, 248, 0.13) 0, rgba(56, 189, 248, 0) 32%),
    linear-gradient(180deg, var(--bg-top) 0, var(--bg) 310px),
    var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

:root[data-theme="kitty"] body {
  background:
    radial-gradient(circle at 12% 0, rgba(255, 79, 163, 0.24) 0, rgba(255, 79, 163, 0) 32%),
    radial-gradient(circle at 90% 6%, rgba(255, 212, 59, 0.22) 0, rgba(255, 212, 59, 0) 29%),
    linear-gradient(180deg, var(--bg-top) 0, var(--bg) 310px),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button-link {
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:active,
.button-link:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

button:focus-visible,
.button-link:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 760;
  text-decoration: none;
}

i[data-lucide] {
  width: 18px;
  height: 18px;
  stroke-width: 2.1;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 12px 104px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin: -12px -12px 10px;
  padding: calc(12px + env(safe-area-inset-top)) 12px 10px;
  background: rgba(7, 10, 18, 0.86);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

.brand-block,
.header-actions,
.quick-actions,
.panel-head,
.hero-row,
.item-row,
.item-actions,
.bottom-nav button,
.top-tabs button,
.primary,
.ghost-btn {
  display: flex;
  align-items: center;
}

.brand-block {
  position: relative;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, #0b1120 0, #164e63 45%, #0f766e 100%);
  color: #fff;
  font-weight: 850;
  letter-spacing: 0;
  box-shadow: 0 14px 30px rgba(25, 198, 163, 0.16), 0 10px 24px rgba(0, 0, 0, 0.38);
}

.brand-kitty {
  display: none;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  overflow: hidden;
  font-size: 25px;
  line-height: 1.08;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h2 {
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 0;
}

.header-actions {
  gap: 8px;
  flex: 0 0 auto;
}

.role-pill,
.soft-pill,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.78);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: var(--tap);
  padding: 0;
}

.theme-select {
  width: auto;
  min-width: 76px;
  min-height: 38px;
  padding: 0 30px 0 10px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 760;
}

.top-tabs {
  position: sticky;
  top: calc(65px + env(safe-area-inset-top));
  z-index: 12;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -12px 12px;
  padding: 4px 12px 12px;
  background: linear-gradient(180deg, rgba(7, 10, 18, 0.96), rgba(7, 10, 18, 0.78));
  backdrop-filter: blur(14px);
  scrollbar-width: none;
  scroll-padding-inline: 12px;
}

.top-tabs::-webkit-scrollbar,
.chip-row::-webkit-scrollbar {
  display: none;
}

.top-tabs button {
  gap: 8px;
  flex: 0 0 auto;
  min-width: max-content;
  min-height: 44px;
  padding: 0 13px;
  border-color: rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.78);
  color: #cbd5e1;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

.top-tabs button.active {
  border-color: rgba(94, 234, 212, 0.5);
  background: linear-gradient(135deg, #0f766e, #1d4ed8);
  color: #fff;
}

.section-menu-btn,
.sheet-backdrop,
.section-sheet {
  display: none;
}

.section-menu-btn {
  width: 100%;
  justify-content: space-between;
  gap: 12px;
  padding: 0 13px;
  border-color: rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.84);
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

.section-menu-btn > span,
.sheet-head,
.section-grid button {
  display: flex;
  align-items: center;
}

.section-menu-btn > span {
  gap: 9px;
  min-width: 0;
  font-weight: 800;
}

#sectionMenuLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(2px);
}

.section-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 45;
  width: min(520px, 100%);
  max-height: min(76dvh, 620px);
  transform: translateX(-50%);
  gap: 12px;
  overflow-y: auto;
  padding: 10px 12px calc(18px + env(safe-area-inset-bottom));
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background:
    linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(7, 10, 18, 0.98)),
    var(--bg);
  box-shadow: 0 -24px 54px rgba(0, 0, 0, 0.48);
}

.sheet-handle {
  justify-self: center;
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.45);
}

.sheet-head {
  justify-content: space-between;
  gap: 12px;
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.section-grid button {
  justify-content: flex-start;
  gap: 9px;
  min-width: 0;
  padding: 0 12px;
  border-color: rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.78);
  color: #cbd5e1;
  font-weight: 780;
}

.section-grid button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-grid button.active {
  border-color: rgba(94, 234, 212, 0.5);
  background: rgba(20, 184, 166, 0.16);
  color: var(--accent-dark);
}

.view {
  display: grid;
  gap: 12px;
}

.hidden {
  display: none !important;
}

.summary-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
  gap: 12px;
}

.balance-hero,
.metric,
.tool-panel,
.notice,
.data-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.balance-hero {
  min-height: 164px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(25, 198, 163, 0.18), rgba(56, 189, 248, 0.12) 58%, rgba(167, 139, 250, 0.12)),
    var(--surface);
}

.balance-hero > span,
.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 620;
}

.balance-hero strong {
  display: block;
  margin: 9px 0 20px;
  font-size: clamp(38px, 9vw, 62px);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero-row {
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.hero-row button {
  min-height: 42px;
  padding: 0 13px;
  border-color: rgba(94, 234, 212, 0.34);
  color: var(--accent-dark);
  font-weight: 780;
}

.metric-stack {
  display: grid;
  gap: 12px;
}

.metric {
  padding: 15px;
  background:
    linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(13, 20, 34, 0.96)),
    var(--surface);
}

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 29px;
  line-height: 1;
  letter-spacing: 0;
}

.quick-actions {
  gap: 9px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.quick-actions button,
.primary,
.ghost-btn {
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 780;
}

.primary {
  border-color: var(--accent);
  background: linear-gradient(135deg, #0f9f87, #087db2);
  color: #fff;
  box-shadow: 0 12px 26px rgba(25, 198, 163, 0.22), 0 8px 18px rgba(0, 0, 0, 0.28);
}

.primary:hover {
  background: linear-gradient(135deg, #14b8a6, #0284c7);
}

:root[data-theme="kitty"] .app-header,
:root[data-theme="kitty"] .top-tabs,
:root[data-theme="kitty"] .bottom-nav {
  border-color: rgba(255, 79, 163, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 249, 253, 0.96), rgba(255, 231, 243, 0.92));
  box-shadow: 0 12px 28px rgba(219, 39, 119, 0.12);
}

:root[data-theme="kitty"] h1,
:root[data-theme="kitty"] h2 {
  color: #36142c;
}

:root[data-theme="kitty"] .brand-mark {
  border: 1px solid rgba(255, 255, 255, 0.72);
  background:
    linear-gradient(145deg, #ff4fa3 0, #ff88c2 54%, #ffd43b 100%);
  color: #4a1738;
  box-shadow: 0 16px 30px rgba(255, 79, 163, 0.32), 0 6px 14px rgba(255, 212, 59, 0.22);
}

:root[data-theme="kitty"] .brand-mark::after {
  content: "\2661";
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(219, 39, 119, 0.22);
  border-radius: 999px;
  background: #fff;
  color: #ff4fa3;
  font-size: 12px;
  line-height: 1;
  box-shadow: 0 6px 14px rgba(219, 39, 119, 0.18);
}

:root[data-theme="kitty"] .brand-kitty {
  position: absolute;
  left: 26px;
  top: -8px;
  z-index: 2;
  display: block;
  width: 32px;
  height: 27px;
  border: 1px solid rgba(219, 39, 119, 0.22);
  border-radius: 46% 46% 44% 44%;
  background: #fff;
  box-shadow: 0 8px 18px rgba(219, 39, 119, 0.2);
  pointer-events: none;
}

:root[data-theme="kitty"] .brand-kitty::before,
:root[data-theme="kitty"] .brand-kitty::after {
  content: "";
  position: absolute;
  top: -4px;
  width: 10px;
  height: 10px;
  border: 1px solid rgba(219, 39, 119, 0.22);
  border-right: 0;
  border-bottom: 0;
  border-radius: 3px;
  background: #fff;
  transform: rotate(45deg);
}

:root[data-theme="kitty"] .brand-kitty::before {
  left: 4px;
}

:root[data-theme="kitty"] .brand-kitty::after {
  right: 4px;
}

:root[data-theme="kitty"] .kitty-bow {
  position: absolute;
  top: -6px;
  right: -4px;
  width: 14px;
  height: 10px;
}

:root[data-theme="kitty"] .kitty-bow::before,
:root[data-theme="kitty"] .kitty-bow::after {
  content: "";
  position: absolute;
  top: 1px;
  width: 8px;
  height: 8px;
  border-radius: 7px 2px 7px 2px;
  background: #ff4fa3;
  box-shadow: inset 0 -1px 0 rgba(74, 23, 56, 0.12);
}

:root[data-theme="kitty"] .kitty-bow::before {
  left: 0;
  transform: rotate(-28deg);
}

:root[data-theme="kitty"] .kitty-bow::after {
  right: 0;
  transform: rotate(28deg);
}

:root[data-theme="kitty"] .kitty-eye,
:root[data-theme="kitty"] .kitty-nose {
  position: absolute;
  display: block;
}

:root[data-theme="kitty"] .kitty-eye {
  top: 12px;
  width: 3px;
  height: 5px;
  border-radius: 999px;
  background: #36142c;
}

:root[data-theme="kitty"] .kitty-eye.left {
  left: 9px;
}

:root[data-theme="kitty"] .kitty-eye.right {
  right: 9px;
}

:root[data-theme="kitty"] .kitty-nose {
  left: 50%;
  top: 16px;
  width: 5px;
  height: 4px;
  border-radius: 999px;
  background: #ffd43b;
  transform: translateX(-50%);
}

:root[data-theme="kitty"] .role-pill,
:root[data-theme="kitty"] .soft-pill,
:root[data-theme="kitty"] .badge {
  border-color: rgba(255, 79, 163, 0.34);
  background: rgba(255, 231, 243, 0.86);
  color: #9d174d;
}

:root[data-theme="kitty"] .theme-select,
:root[data-theme="kitty"] button,
:root[data-theme="kitty"] .button-link {
  border-color: rgba(255, 79, 163, 0.32);
}

:root[data-theme="kitty"] .balance-hero,
:root[data-theme="kitty"] .metric,
:root[data-theme="kitty"] .tool-panel,
:root[data-theme="kitty"] .notice,
:root[data-theme="kitty"] .section-menu-btn,
:root[data-theme="kitty"] .section-sheet {
  background:
    linear-gradient(180deg, rgba(255, 250, 253, 0.98), rgba(255, 233, 244, 0.96)),
    var(--surface);
  box-shadow: 0 16px 34px rgba(219, 39, 119, 0.14);
}

:root[data-theme="kitty"] .balance-hero {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 79, 163, 0.22), rgba(255, 155, 208, 0.18) 52%, rgba(255, 212, 59, 0.2)),
    var(--surface);
}

:root[data-theme="kitty"] .balance-hero::after {
  content: "\2661";
  position: absolute;
  right: 14px;
  bottom: 8px;
  display: grid;
  place-items: center;
  width: 82px;
  height: 62px;
  border: 1px solid rgba(219, 39, 119, 0.1);
  border-radius: 46% 46% 42% 42%;
  background:
    radial-gradient(circle at 34% 45%, #36142c 0 3px, transparent 4px),
    radial-gradient(circle at 66% 45%, #36142c 0 3px, transparent 4px),
    radial-gradient(ellipse at 50% 58%, #ffd43b 0 6px, transparent 7px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.4));
  color: rgba(255, 79, 163, 0.56);
  font-size: 16px;
  box-shadow: 0 12px 26px rgba(219, 39, 119, 0.1);
  opacity: 0.58;
  pointer-events: none;
}

:root[data-theme="kitty"] .balance-hero::before {
  content: "";
  position: absolute;
  right: 67px;
  bottom: 61px;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #fff;
  transform: rotate(45deg);
  opacity: 0.62;
}

:root[data-theme="kitty"] .data-item {
  border-color: rgba(255, 79, 163, 0.24);
  box-shadow: 0 10px 24px rgba(219, 39, 119, 0.1);
}

:root[data-theme="kitty"] .brand-mark,
:root[data-theme="kitty"] .primary,
:root[data-theme="kitty"] .button-link {
  background: linear-gradient(135deg, #ff4fa3, #ff8cc8 56%, #ffd43b);
  color: #4a1738;
  box-shadow: 0 14px 28px rgba(255, 79, 163, 0.26), 0 6px 16px rgba(255, 212, 59, 0.18);
}

:root[data-theme="kitty"] .primary:hover,
:root[data-theme="kitty"] .top-tabs button.active {
  border-color: rgba(219, 39, 119, 0.36);
  background: linear-gradient(135deg, #ff3f9b, #ff74bb 56%, #ffd43b);
  color: #4a1738;
}

:root[data-theme="kitty"] .bottom-nav button.active {
  border-color: rgba(255, 79, 163, 0.46);
  background: linear-gradient(180deg, rgba(255, 231, 243, 0.96), rgba(255, 203, 226, 0.86));
  color: #db2777;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.64), 0 8px 16px rgba(219, 39, 119, 0.12);
}

:root[data-theme="kitty"] input,
:root[data-theme="kitty"] select,
:root[data-theme="kitty"] textarea,
:root[data-theme="kitty"] input[type="file"],
:root[data-theme="kitty"] .method-preview,
:root[data-theme="kitty"] .form-hint,
:root[data-theme="kitty"] .data-item {
  background: rgba(255, 255, 255, 0.84);
}

:root[data-theme="kitty"] input[type="file"]::file-selector-button {
  background: rgba(255, 240, 247, 0.94);
  color: #4a1738;
}

:root[data-theme="kitty"] .badge.pending {
  border-color: rgba(255, 190, 11, 0.42);
  background: rgba(255, 241, 184, 0.7);
  color: #a15c00;
}

:root[data-theme="kitty"] .badge.approved,
:root[data-theme="kitty"] .badge.done,
:root[data-theme="kitty"] .badge.queued,
:root[data-theme="kitty"] .badge.processing {
  border-color: rgba(16, 185, 129, 0.34);
  background: rgba(209, 250, 229, 0.78);
  color: #047857;
}

:root[data-theme="kitty"] .badge.rejected,
:root[data-theme="kitty"] .badge.failed,
:root[data-theme="kitty"] .badge.refunded {
  border-color: rgba(225, 29, 72, 0.32);
  background: rgba(255, 228, 230, 0.8);
  color: #be123c;
}

:root[data-theme="kitty"] .danger {
  border-color: rgba(225, 29, 72, 0.34);
  background: rgba(255, 228, 230, 0.56);
}

:root[data-theme="kitty"] .toast {
  min-height: 48px;
  padding-left: 44px;
  border-color: rgba(255, 79, 163, 0.34);
  background:
    linear-gradient(180deg, rgba(255, 250, 253, 0.98), rgba(255, 231, 243, 0.96)),
    #fff9fd;
  color: #4a1738;
  box-shadow: 0 18px 36px rgba(219, 39, 119, 0.18);
}

:root[data-theme="kitty"] .toast::before {
  content: "\2661";
  position: absolute;
  left: 14px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff4fa3, #ff8cc8);
  color: #fff;
  font-size: 13px;
  transform: translateY(-50%);
  box-shadow: 0 6px 14px rgba(219, 39, 119, 0.2);
}

.ghost-btn {
  min-height: 38px;
  border-color: transparent;
  background: transparent;
  color: var(--accent-dark);
}

.tool-panel {
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(13, 20, 34, 0.96)),
    var(--surface);
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.item-list {
  display: grid;
  gap: 9px;
}

.data-item {
  padding: 12px;
  box-shadow: none;
  background: rgba(13, 20, 34, 0.86);
}

.item-row {
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.item-title {
  font-weight: 780;
  line-height: 1.25;
  word-break: break-word;
}

.item-meta,
.item-subline {
  color: var(--muted);
  font-size: 13px;
}

.item-meta {
  margin-top: 5px;
  word-break: break-word;
}

.item-subline {
  margin-top: 8px;
  word-break: break-word;
}

.item-extra {
  margin-top: 10px;
}

.item-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 12px;
}

.item-actions button,
.item-actions .button-link {
  min-height: 38px;
  padding: 0 12px;
  font-weight: 760;
}

.assignment-panel {
  scroll-margin-top: calc(88px + env(safe-area-inset-top));
}

.badge.pending {
  border-color: rgba(251, 191, 36, 0.38);
  background: rgba(251, 191, 36, 0.13);
  color: var(--amber);
}

.badge.approved,
.badge.done,
.badge.queued,
.badge.processing {
  border-color: rgba(52, 211, 153, 0.38);
  background: rgba(52, 211, 153, 0.12);
  color: var(--ok);
}

.badge.rejected,
.badge.failed,
.badge.refunded {
  border-color: rgba(251, 113, 133, 0.38);
  background: rgba(251, 113, 133, 0.12);
  color: var(--danger);
}

.badge.off {
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
}

.danger {
  border-color: rgba(251, 113, 133, 0.42);
  color: var(--danger);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(140px, 0.7fr) minmax(120px, 0.5fr);
  gap: 10px;
  align-items: end;
}

.form-grid.single {
  grid-template-columns: 1fr;
}

.compact-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.inline-controls {
  display: grid;
  grid-template-columns: minmax(90px, 0.35fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.method-editor {
  margin-top: 2px;
}

.memo-box {
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 12px;
  color: var(--text);
  word-break: break-word;
}

.method-preview,
.form-hint {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 13, 24, 0.46);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}

.method-preview {
  display: grid;
  gap: 4px;
}

.method-preview strong {
  color: var(--text);
  font-size: 14px;
}

.method-preview small {
  display: block;
  overflow-wrap: anywhere;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 690;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 13, 24, 0.82);
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

input[type="file"] {
  padding: 8px;
  background: rgba(8, 13, 24, 0.82);
}

input[type="file"]::file-selector-button {
  min-height: 34px;
  margin-right: 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(17, 24, 39, 0.94);
  color: var(--text);
  font: inherit;
  font-weight: 760;
  cursor: pointer;
}

textarea {
  min-height: 118px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(56, 189, 248, 0.72);
  box-shadow: var(--focus);
}

.wide,
.span-2 {
  grid-column: 1 / -1;
}

.item-list > .wide {
  width: 100%;
  margin-top: 10px;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 1px;
  scrollbar-width: none;
}

.chip-row button {
  min-width: max-content;
  min-height: 42px;
  padding: 0 13px;
  font-weight: 760;
}

.chip-row button.active {
  border-color: rgba(94, 234, 212, 0.44);
  background: rgba(20, 184, 166, 0.16);
  color: var(--accent-dark);
}

.progress {
  height: 7px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
}

.progress span {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  max-width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.model-toggle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.toggle-chip {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-height: 46px;
  padding: 0 12px;
  text-align: left;
}

.toggle-chip.active {
  border-color: rgba(94, 234, 212, 0.44);
  background: rgba(20, 184, 166, 0.16);
  color: var(--accent-dark);
}

.toggle-chip small {
  color: var(--muted);
  font-size: 11px;
}

.notice {
  display: flex;
  gap: 12px;
  padding: 16px;
}

.notice-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: rgba(20, 184, 166, 0.16);
  color: var(--accent-dark);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 25;
  width: min(760px, 100%);
  transform: translateX(-50%);
  display: none;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 8px 9px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(7, 10, 18, 0.9);
  backdrop-filter: blur(18px);
  box-shadow: 0 -18px 34px rgba(0, 0, 0, 0.35);
}

.bottom-nav button {
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 52px;
  padding: 0 3px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 780;
}

.bottom-nav button span {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-nav button.active {
  border-color: rgba(94, 234, 212, 0.36);
  background: rgba(20, 184, 166, 0.16);
  color: var(--accent-dark);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 80px;
  z-index: 35;
  width: min(520px, calc(100% - 28px));
  transform: translateX(-50%);
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.96);
  color: var(--text);
  box-shadow: var(--shadow);
}

::placeholder {
  color: var(--muted-2);
  opacity: 1;
}

@media (min-width: 781px) {
  .app-shell {
    padding-bottom: 40px;
  }
}

@media (max-width: 780px) {
  body {
    font-size: 14px;
  }

  .app-shell {
    padding: calc(10px + env(safe-area-inset-top)) 10px 102px;
  }

  .app-header {
    margin: -10px -10px 8px;
    padding: calc(10px + env(safe-area-inset-top)) 10px 9px;
  }

  .top-tabs {
    display: none;
  }

  .section-menu-btn {
    position: sticky;
    top: calc(61px + env(safe-area-inset-top));
    z-index: 12;
    display: flex;
    margin: 0 0 10px;
  }

  .sheet-backdrop:not(.hidden) {
    display: block;
  }

  .section-sheet:not(.hidden) {
    display: grid;
  }

  .summary-layout,
  .admin-grid,
  .form-grid,
  .compact-form,
  .inline-controls,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-actions .primary {
    grid-column: 1 / -1;
  }

  .quick-actions button {
    min-width: 0;
    min-height: 54px;
    padding-inline: 10px;
  }

  .quick-actions button span {
    overflow-wrap: anywhere;
    text-align: center;
    line-height: 1.15;
  }

  #leaderboardPeriods,
  #adminReportPeriods,
  #adminShopOrderFilters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  #leaderboardPeriods button,
  #adminReportPeriods button,
  #adminShopOrderFilters button {
    min-width: 0;
  }

  .bottom-nav {
    display: grid;
  }

  .tool-panel,
  .data-item,
  .metric,
  .balance-hero {
    box-shadow: var(--shadow-soft);
  }

  .item-actions {
    justify-content: stretch;
  }

  .item-actions button,
  .item-actions .button-link {
    flex: 1 1 calc(50% - 7px);
  }
}

@media (max-width: 480px) {
  .brand-mark {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
  }

  h1 {
    font-size: 22px;
  }

  .role-pill {
    display: none;
  }

  .theme-select {
    min-width: 74px;
    max-width: 82px;
    padding-left: 8px;
  }

  .icon-btn {
    width: 44px;
    min-height: 44px;
  }

  .top-tabs button {
    justify-content: center;
    min-width: max-content;
    padding: 0 12px;
    font-size: 13px;
  }

  .balance-hero {
    min-height: 148px;
    padding: 16px;
  }

  .balance-hero strong {
    font-size: clamp(42px, 15vw, 58px);
  }

  .hero-row {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-row button {
    width: 100%;
  }

  .panel-head {
    align-items: flex-start;
  }

  .metric strong {
    font-size: 27px;
  }

  textarea {
    min-height: 108px;
  }
}

@media (max-width: 370px) {
  .bottom-nav {
    gap: 3px;
    padding-inline: 5px;
  }

  .bottom-nav button {
    font-size: 10px;
  }

  i[data-lucide] {
    width: 17px;
    height: 17px;
  }
}
