:root {
  --bg: #17181c;
  --panel: #1e1f24;
  --panel-2: #24262d;
  --panel-3: #2b2d35;
  --line: #34363f;
  --text: #f2f3f5;
  --muted: #949ba4;
  --brand: #5865f2;
  --brand-hover: #4752c4;
  --green: #23a559;
  --red: #da373c;
  --yellow: #f0b232;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: #111214; border-right: 1px solid #202225; padding: 22px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 24px; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--brand); box-shadow: 0 8px 24px #5865f233; }
.brand-mark svg { width: 19px; }
.nav-label { color: #686d75; padding: 8px 10px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 11px; border-radius: 6px; color: var(--muted); margin: 2px 0; font-size: 14px; font-weight: 550; }
.nav-item.active, .nav-item:hover { background: #27292f; color: var(--text); }
.nav-icon { width: 18px; text-align: center; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid #292b30; }
.user { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 9px; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(145deg, #5865f2, #9b84ee); font-weight: 800; }
.user-name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.user-tag { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 5px; padding: 7px; }
.icon-btn:hover { background: #292b31; color: var(--text); }

.content { min-width: 0; }
.topbar { height: 62px; display: flex; align-items: center; justify-content: space-between; padding: 0 34px; border-bottom: 1px solid var(--line); background: #1a1b1fdd; backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 4; }
.topbar-title { font-size: 15px; font-weight: 700; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); padding: 6px 10px; border-radius: 99px; font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); }
.page { max-width: 1180px; margin: 0 auto; padding: 34px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
h1 { font-size: 27px; line-height: 1.2; margin: 0 0 7px; letter-spacing: -.025em; }
.subtitle { color: var(--muted); margin: 0; font-size: 14px; }

.button { border: 0; border-radius: 5px; padding: 10px 15px; color: #fff; background: var(--brand); font-weight: 650; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.button:hover { background: var(--brand-hover); }
.button.secondary { color: var(--text); background: var(--panel-3); border: 1px solid var(--line); }
.button.secondary:hover { background: #333640; }
.button.danger { background: transparent; color: #ff777b; border: 1px solid #5b3034; }
.button.danger:hover { background: #3b2427; }
.button:disabled { opacity: .55; cursor: not-allowed; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.stat { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); padding: 17px 18px; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 650; }
.stat-value { font-size: 23px; font-weight: 760; margin-top: 6px; }
.stat-note { color: var(--muted); font-size: 11px; margin-left: 6px; font-weight: 500; }

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: border-color .15s, transform .15s; }
.card:hover { border-color: #484b58; transform: translateY(-1px); }
.card-main { padding: 18px; }
.card-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.card-title { font-size: 16px; font-weight: 730; margin: 0 0 7px; }
.wallet { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.rule-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.rule { background: var(--panel-2); border: 1px solid #30323a; border-radius: 6px; padding: 12px; }
.rule-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 750; }
.rule-value { margin-top: 7px; font-size: 14px; font-weight: 700; }
.rule-detail { margin-top: 4px; color: var(--muted); font-size: 11px; }
.card-foot { border-top: 1px solid var(--line); padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; background: #1b1c21; }
.card-actions { display: flex; gap: 4px; }
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; cursor: pointer; border-radius: 99px; background: #4e5058; transition: .2s; }
.slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; border-radius: 50%; background: white; transition: .2s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(16px); }
.empty { grid-column: 1 / -1; border: 1px dashed #42454f; border-radius: var(--radius); padding: 64px 20px; text-align: center; background: #1b1c20; }
.empty-icon { width: 52px; height: 52px; margin: 0 auto 15px; border-radius: 16px; display: grid; place-items: center; background: #282a31; color: var(--brand); font-size: 24px; }
.empty h2 { margin: 0 0 8px; font-size: 18px; }
.empty p { color: var(--muted); margin: 0 0 20px; font-size: 13px; }

.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
.form-panel, .summary-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.section { padding: 22px; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: 0; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 17px; }
.section-title h2 { margin: 0; font-size: 15px; }
.section-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; }
.field.full { grid-column: 1 / -1; }
label { display: block; margin-bottom: 7px; color: #c8cad0; font-size: 12px; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #3d404a; border-radius: 5px; background: #121317; color: var(--text); padding: 10px 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 2px #5865f226; }
textarea { min-height: 85px; resize: vertical; }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 42px; }
.suffix { position: absolute; right: 11px; top: 10px; color: var(--muted); font-size: 13px; }
.hint { color: #777d87; font-size: 11px; margin-top: 6px; line-height: 1.4; }
.summary-panel { position: sticky; top: 82px; padding: 18px; }
.summary-panel h3 { margin: 0 0 15px; font-size: 14px; }
.summary-row { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid #30323a; font-size: 12px; }
.summary-row span:first-child { color: var(--muted); }
.summary-row span:last-child { text-align: right; font-weight: 650; }
.form-actions { display: flex; justify-content: space-between; gap: 10px; padding: 16px 22px; background: #191a1f; border-top: 1px solid var(--line); }
.actions-right { display: flex; gap: 9px; margin-left: auto; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: radial-gradient(circle at 50% 20%, #2b2e4b 0, #17181c 42%, #111214 100%); }
.login-card { width: min(430px, 100%); padding: 34px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 28px 80px #0008; text-align: center; }
.login-logo { width: 56px; height: 56px; margin: 0 auto 19px; display: grid; place-items: center; border-radius: 18px; background: var(--brand); font-size: 26px; }
.login-card h1 { font-size: 23px; }
.login-card p { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 8px 0 24px; }
.telegram-button { background: #229ed9; width: 100%; }
.telegram-button:hover { background: #168dcc; }
.demo-separator { display: flex; align-items: center; gap: 12px; color: #686d75; font-size: 11px; margin: 17px 0; }
.demo-separator::before, .demo-separator::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.login-note { margin-top: 19px !important; font-size: 11px !important; }
.toast { position: fixed; right: 22px; bottom: 22px; padding: 12px 15px; background: #24262c; border: 1px solid #42454f; border-radius: 7px; box-shadow: 0 12px 35px #0008; font-size: 13px; z-index: 10; transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: #773b40; color: #ffb6b8; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 72px 1fr; }
  .sidebar { padding: 18px 9px; }
  .brand span:last-child, .nav-label, .nav-item span:last-child, .user-info, .sidebar-foot .icon-btn { display: none; }
  .brand, .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }
  .user { grid-template-columns: 1fr; justify-items: center; }
  .form-layout { grid-template-columns: 1fr; }
  .summary-panel { position: static; }
}
@media (max-width: 650px) {
  .shell { display: block; }
  .sidebar { display: none; }
  .topbar { padding: 0 18px; }
  .page { padding: 23px 16px 90px; }
  .page-head { align-items: stretch; flex-direction: column; }
  .stats, .cards, .fields { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .rule-grid { grid-template-columns: 1fr; }
}
