/* ============================================================
   SteamPunk admin — тёмная «Steam» тема: графит + сталь, акцент
   Steam-blue (#66c0f4), CTA-зелёный (#5c9e2f). Glassmorphism, свечение.
   Класс-контракт (card/stat/list-item/badge/nav/toast/grid) совместим
   с премиум-панелью GiftBot.
   ============================================================ */
:root {
  --steam:     #66c0f4;
  --steam-2:   #1b9ef3;
  --green:     #5c9e2f;
  --green-2:   #8bc34a;
  --violet:    #7d5cff;
  --coral:     #ff5d77;
  --amber:     #ffb02e;
  --cyan:      #21c7e6;

  --bg:        #0d1117;
  --bg-2:      #0a0e14;
  --ink:       #e6edf3;
  --muted:     #8b98a9;
  --surface:   rgba(28, 35, 48, .72);
  --glass:     rgba(20, 26, 37, .72);
  --panel-2:   rgba(120, 140, 175, .10);
  --line:      rgba(120, 140, 175, .18);
  --danger:    #ff5d77;
  --warn:      #ffb02e;

  --grad-primary: linear-gradient(135deg, #1b9ef3 0%, #66c0f4 100%);
  --grad-ok:      linear-gradient(135deg, #5c9e2f 0%, #8bc34a 100%);
  --grad-danger:  linear-gradient(135deg, #ff5d77 0%, #c62a45 100%);
  --grad-brand:   linear-gradient(120deg, #66c0f4 0%, #7d5cff 60%, #1b9ef3 100%);

  --grad-s1: linear-gradient(135deg, #1b9ef3, #2667ff);
  --grad-s2: linear-gradient(135deg, #7d5cff, #5b3edb);
  --grad-s3: linear-gradient(135deg, #5c9e2f, #3e7a1c);
  --grad-s4: linear-gradient(135deg, #21c7e6, #128fb0);
  --grad-s5: linear-gradient(135deg, #ffb02e, #ff8a2e);
  --grad-s6: linear-gradient(135deg, #ff5d77, #c62a45);

  --radius: 16px; --radius-lg: 20px;
  --shadow: 0 22px 48px -22px rgba(0, 0, 0, .7);
  --shadow-sm: 0 14px 30px -18px rgba(0, 0, 0, .65);
  --ring: 0 0 0 4px rgba(102, 192, 244, .22);
  --glass-blur: blur(18px) saturate(140%);
}

* { box-sizing: border-box; }

body {
  margin: 0; font-family: "Inter", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--ink); font-size: 14px; line-height: 1.5; background-color: var(--bg);
  -webkit-font-smoothing: antialiased; min-height: 100vh; overflow-x: hidden;
}
body::before, body::after {
  content: ""; position: fixed; z-index: 0; pointer-events: none;
  border-radius: 50%; filter: blur(80px); opacity: .35;
}
body::before { width: 50vw; height: 50vw; top: -18vw; right: -12vw;
  background: radial-gradient(circle, #1b9ef3, transparent 66%); }
body::after { width: 46vw; height: 46vw; bottom: -20vw; left: -14vw;
  background: radial-gradient(circle, #7d5cff, transparent 66%); }

#login, #app { position: relative; z-index: 1; }
a { color: var(--steam); text-decoration: none; }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 6px; font-size: 12px; font-family: "JetBrains Mono", ui-monospace, monospace; }

button {
  font: inherit; font-weight: 700; cursor: pointer; border: none; border-radius: 12px;
  padding: 10px 17px; color: #fff; background: var(--grad-primary);
  box-shadow: 0 12px 28px -10px rgba(27, 158, 243, .55), inset 0 1px 0 rgba(255, 255, 255, .18);
  transition: transform .14s, box-shadow .2s, filter .2s;
}
button:hover { transform: translateY(-1px); filter: brightness(1.08); }
button:active { transform: translateY(0); }
button.ghost { background: rgba(120, 140, 175, .12); color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
button.ghost:hover { border-color: rgba(102, 192, 244, .45); color: var(--steam); }
button.ok { background: var(--grad-ok); box-shadow: 0 12px 26px -10px rgba(92, 158, 47, .5); }
button.danger { background: var(--grad-danger); box-shadow: 0 12px 26px -10px rgba(255, 93, 119, .5); }
button.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }

input, textarea, select {
  font: inherit; width: 100%; color: var(--ink);
  background: rgba(13, 17, 23, .6); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 13px; transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--steam); background: rgba(13, 17, 23, .9); box-shadow: var(--ring); }
textarea { min-height: 120px; resize: vertical; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13px; }
label { display: block; margin: 12px 0 5px; color: var(--muted); font-size: 13px; font-weight: 600; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 130px; }
.checkbox { display: flex; align-items: center; gap: 9px; margin: 9px 0; }
.checkbox input { width: auto; accent-color: var(--steam); transform: scale(1.15); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.right { text-align: right; }

#app {
  display: grid; grid-template-columns: 240px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "hd hd" "nav main"; min-height: 100vh;
}
header {
  grid-area: hd; position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; padding: 14px 26px;
  background: var(--glass); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--line);
}
header .brand { font-family: "Manrope", sans-serif; font-weight: 800; font-size: 21px; letter-spacing: -.02em;
  background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
header .actions { display: flex; align-items: center; gap: 12px; }
#bot-name { font-weight: 700; font-size: 13px; color: var(--steam);
  background: rgba(102, 192, 244, .12); padding: 6px 13px; border-radius: 999px; border: 1px solid rgba(102, 192, 244, .22); }

nav {
  grid-area: nav; position: sticky; top: 65px; align-self: start;
  display: flex; flex-direction: column; gap: 6px; padding: 18px 14px; min-height: calc(100vh - 65px);
  background: rgba(13, 17, 23, .5); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--line);
}
nav button { background: transparent; color: var(--muted); box-shadow: none; text-align: left;
  padding: 12px 14px; border-radius: 12px; font-weight: 700; display: flex; align-items: center; gap: 11px; }
nav button::before { font-size: 16px; }
nav button[data-tab="dashboard"]::before { content: "📊"; }
nav button[data-tab="keys"]::before      { content: "🔑"; }
nav button[data-tab="channels"]::before  { content: "📡"; }
nav button[data-tab="zadania"]::before    { content: "🎯"; }
nav button[data-tab="users"]::before     { content: "👥"; }
nav button[data-tab="campaigns"]::before { content: "📈"; }
nav button[data-tab="broadcasts"]::before{ content: "📣"; }
nav button[data-tab="texts"]::before     { content: "📝"; }
nav button[data-tab="settings"]::before  { content: "⚙️"; }
nav button:hover { transform: none; background: rgba(102, 192, 244, .1); color: var(--ink); }
nav button.active { background: var(--grad-primary); color: #fff; box-shadow: 0 10px 24px -12px rgba(27, 158, 243, .6); }

main { grid-area: main; padding: 26px; max-width: 1180px; width: 100%; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  animation: rise .4s cubic-bezier(.2, .7, .3, 1) both; }
.card h3 { margin: 0 0 14px; font-family: "Manrope", sans-serif; font-size: 17px; font-weight: 800; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.stat { position: relative; overflow: hidden; color: #fff; border-radius: var(--radius); padding: 20px 18px;
  box-shadow: var(--shadow); animation: rise .5s cubic-bezier(.2, .7, .3, 1) both; }
.stat::after { content: ""; position: absolute; right: -24px; top: -24px; width: 96px; height: 96px;
  border-radius: 50%; background: rgba(255, 255, 255, .14); }
.stat .n { position: relative; font-family: "Manrope", sans-serif; font-size: 30px; font-weight: 800; line-height: 1; }
.stat .l { position: relative; color: rgba(255, 255, 255, .92); font-size: 13px; font-weight: 600; margin-top: 8px; }
.grid .stat:nth-child(6n+1) { background: var(--grad-s1); }
.grid .stat:nth-child(6n+2) { background: var(--grad-s2); }
.grid .stat:nth-child(6n+3) { background: var(--grad-s3); }
.grid .stat:nth-child(6n+4) { background: var(--grad-s4); }
.grid .stat:nth-child(6n+5) { background: var(--grad-s5); }
.grid .stat:nth-child(6n+6) { background: var(--grad-s6); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:hover td { background: rgba(102, 192, 244, .06); }
td code { font-size: 11px; }

.badge { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; }
.badge.s1 { background: var(--grad-s1); } .badge.s2 { background: var(--grad-s2); } .badge.s3 { background: var(--grad-s3); }
.badge.on, .badge.active, .badge.running { background: var(--grad-ok); }
.badge.off, .badge.cancelled, .badge.stopped, .badge.failed { background: var(--grad-danger); }
.badge.done { background: var(--grad-s2); } .badge.draft { background: #6b7689; }

.list-item { display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 15px 18px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px;
  background: var(--surface); box-shadow: var(--shadow-sm); backdrop-filter: var(--glass-blur); }
.list-item b { font-size: 15px; } .list-item .meta { color: var(--muted); font-size: 13px; margin-top: 5px; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; }

.progress { height: 10px; background: rgba(120, 140, 175, .16); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; width: 0; border-radius: 999px; background: var(--grad-primary); transition: width .5s; }

#login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, #14304a 0%, #0a0e14 55%); }
#login .box { width: 366px; max-width: 100%; background: var(--surface);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .8); padding: 34px 30px; animation: rise .5s both; }
#login .box h3 { font-family: "Manrope", sans-serif; font-size: 24px; font-weight: 800; margin: 0 0 8px; text-align: center;
  background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }

#toast { position: fixed; bottom: 24px; right: 24px; z-index: 60; background: rgba(8, 12, 18, .95);
  color: #fff; border: 1px solid var(--line); border-left: 4px solid var(--steam); padding: 14px 20px;
  border-radius: 14px; box-shadow: 0 22px 48px -16px rgba(0, 0, 0, .7); opacity: 0; transform: translateY(14px);
  transition: opacity .3s, transform .3s; max-width: 380px; font-weight: 600; }
#toast.show { opacity: 1; transform: translateY(0); }
#toast.err { border-left-color: var(--danger); }

.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { width: 560px; max-width: 100%; max-height: 88vh; overflow: auto; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv .k { color: var(--muted); }

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  header, nav { background: rgba(13, 17, 23, .96); }
  .card, .list-item, #login .box { background: rgba(22, 27, 38, .97); }
}
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; grid-template-areas: "hd" "nav" "main"; }
  nav { flex-direction: row; overflow-x: auto; min-height: 0; top: 61px; border-right: none; border-bottom: 1px solid var(--line); padding: 10px 14px; }
  nav button { white-space: nowrap; }
  main { padding: 18px; }
}
