:root {
  --bg: #0b1020;
  --bg-soft: #121a33;
  --surface: #161f3d;
  --surface-2: #1d2849;
  --border: #2a3760;
  --text: #e8ecf8;
  --muted: #9aa6c8;
  --brand: #6366f1;
  --brand-2: #0ea5e9;
  --accent: #f97316;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 40px -22px rgba(0, 0, 0, .85);
  --sidebar-w: 252px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(99, 102, 241, .18), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(14, 165, 233, .14), transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; font-weight: 700; letter-spacing: -.015em; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.08rem; }
p { margin: 0 0 .8em; color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; gap: .6rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .58rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; transition: .15s ease; white-space: nowrap; font-size: .9rem;
}
.btn:hover { background: #26325c; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--brand), #4f46e5); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.accent { background: linear-gradient(135deg, var(--accent), #ea580c); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: rgba(239, 68, 68, .16); border-color: rgba(239, 68, 68, .4); color: #fca5a5; }
.btn.danger:hover { background: rgba(239, 68, 68, .28); }
.btn.sm { padding: .32rem .62rem; font-size: .8rem; }
.btn.icon { padding: .38rem .55rem; }
.btn.block { width: 100%; }

/* ----------------------------------------------------------------- cards */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, 0)) , var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.card.pad0 { padding: 0; overflow: hidden; }
.card h3 { display: flex; align-items: center; gap: .5rem; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  padding: .9rem 1.2rem; border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, .02);
}
.card-head h3 { margin: 0; }

.stat { display: flex; flex-direction: column; gap: .25rem; }
.stat .label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; }
.stat .delta { font-size: .78rem; }
.stat .delta.up { color: var(--ok); } .stat .delta.down { color: var(--err); }

.kpi {
  display: flex; align-items: center; gap: .9rem;
  padding: .95rem 1.05rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
}
.kpi .ico {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: rgba(99, 102, 241, .16); font-size: 1.15rem; flex: 0 0 auto;
}

/* ----------------------------------------------------------------- forms */
label.field { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }
label.field > span { font-weight: 600; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .55rem .7rem; width: 100%; outline: none; transition: .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99, 102, 241, .18); }
input[type=checkbox] { width: auto; accent-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
.form-grid { display: grid; gap: .85rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .88rem; color: var(--text); }
.check input { width: auto; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .89rem; }
th, td { text-align: left; padding: .62rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; white-space: nowrap; }
tbody tr:hover { background: rgba(255, 255, 255, .028); }
tbody tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; text-align: right; }

.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .16rem .55rem;
  border-radius: 999px; font-size: .74rem; font-weight: 700; letter-spacing: .02em;
  background: rgba(154, 166, 200, .14); color: var(--muted); border: 1px solid transparent;
}
.badge.ok { background: rgba(34, 197, 94, .15); color: #86efac; }
.badge.warn { background: rgba(245, 158, 11, .16); color: #fcd34d; }
.badge.err { background: rgba(239, 68, 68, .16); color: #fca5a5; }
.badge.info { background: rgba(14, 165, 233, .16); color: #7dd3fc; }
.badge.brand { background: rgba(99, 102, 241, .18); color: #c7d2fe; }

/* ---------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: rgba(10, 15, 32, .72); backdrop-filter: blur(12px);
  border-right: 1px solid var(--border); padding: 1.1rem .85rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brandmark { display: flex; align-items: center; gap: .6rem; padding: .3rem .5rem 1.1rem; }
.brandmark .logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  flex: none;
}
.logo svg { display: block; border-radius: 10px; }
.brandmark b { font-size: 1.05rem; letter-spacing: -.02em; }
.nav-group { margin-bottom: 1rem; }
.nav-group > span {
  display: block; padding: .35rem .6rem; color: var(--muted);
  font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 800;
}
.nav a {
  display: flex; align-items: center; gap: .6rem; padding: .48rem .6rem; border-radius: var(--radius-sm);
  color: var(--muted); font-size: .89rem; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: linear-gradient(90deg, rgba(99, 102, 241, .28), transparent); color: #fff; font-weight: 700; }
.nav a .ic { width: 1.15rem; text-align: center; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 1.4rem; border-bottom: 1px solid var(--border);
  background: rgba(11, 16, 32, .72); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 1.18rem; }
.content { padding: 1.4rem; max-width: 1500px; width: 100%; }
.breadcrumb { color: var(--muted); font-size: .8rem; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); font-weight: 700; font-size: .82rem; flex: 0 0 auto;
}
.avatar.lg { width: 54px; height: 54px; font-size: 1.1rem; }

/* ----------------------------------------------------------------- misc */
.empty { text-align: center; padding: 2.4rem 1rem; color: var(--muted); }
.empty .big { font-size: 2rem; margin-bottom: .4rem; }
.spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255, 255, 255, .25);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; gap: .6rem; padding: 2.6rem; color: var(--muted); }

#toasts { position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 200; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  min-width: 250px; max-width: 380px; padding: .7rem .9rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); box-shadow: var(--shadow);
  animation: slidein .2s ease; font-size: .88rem;
}
.toast.ok { border-color: rgba(34, 197, 94, .45); }
.toast.err { border-color: rgba(239, 68, 68, .5); }
.toast.warn { border-color: rgba(245, 158, 11, .5); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }

.modal-back {
  position: fixed; inset: 0; background: rgba(4, 8, 20, .72); backdrop-filter: blur(3px);
  z-index: 100; display: grid; place-items: center; padding: 1.2rem;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  width: min(680px, 100%); max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow);
}
.modal.wide { width: min(1000px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 1.2rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: .6rem; padding: .9rem 1.2rem; border-top: 1px solid var(--border); }

.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tabs button {
  background: none; border: none; color: var(--muted); font: inherit; font-weight: 600;
  padding: .55rem .85rem; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.active { color: #fff; border-bottom-color: var(--brand); }

.progress { height: 6px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.bar { height: 8px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; min-width: 70px; }
.bar > i { display: block; height: 100%; }

.pill-toggle { display: inline-flex; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px; padding: 2px; }
.pill-toggle button { border: none; background: none; color: var(--muted); padding: .25rem .7rem; border-radius: 999px; font: inherit; font-size: .8rem; cursor: pointer; }
.pill-toggle button.on { background: var(--brand); color: #fff; font-weight: 700; }

.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters input, .filters select { width: auto; min-width: 160px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .7rem 1.1rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; }

/* ---------------------------------------------------------------- public */
.site { max-width: 1180px; margin: 0 auto; padding: 0 1.2rem; }
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 0; position: sticky; top: 0; z-index: 30;
  background: rgba(11, 16, 32, .85); backdrop-filter: blur(12px);
}
.site-nav { display: flex; gap: 1.1rem; align-items: center; }
.site-nav a { color: var(--muted); font-weight: 600; font-size: .92rem; }
.site-nav a:hover { color: #fff; text-decoration: none; }
.hero { padding: 4.5rem 0 3.5rem; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); letter-spacing: -.03em; max-width: 16ch; }
.hero p { font-size: 1.08rem; max-width: 56ch; }
.hero .cta { display: flex; gap: .7rem; margin-top: 1.6rem; flex-wrap: wrap; }
.section { padding: 3rem 0; }
.section > h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
.feature { display: flex; gap: .8rem; align-items: flex-start; }
.feature .ic { font-size: 1.4rem; }
.plan { display: flex; flex-direction: column; gap: .7rem; height: 100%; }
.plan .price { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.plan.featured { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), var(--shadow); }
.plan ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .35rem; }
.plan li::before { content: "✓"; color: var(--ok); margin-right: .5rem; font-weight: 800; }
.trainer-card { text-align: center; }
.trainer-card .avatar { margin: 0 auto .5rem; width: 66px; height: 66px; font-size: 1.4rem; }
.post { display: flex; flex-direction: column; gap: .4rem; }
.post h3 a { color: var(--text); }
.faq-item summary { cursor: pointer; font-weight: 600; padding: .6rem 0; }
.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; padding: 2rem 0; color: var(--muted); }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; }
.auth-card { width: min(430px, 100%); }
.auth-tabs { display: flex; gap: .3rem; margin-bottom: 1rem; background: var(--bg-soft); padding: 3px; border-radius: 999px; }
.auth-tabs button { flex: 1; border: none; background: none; color: var(--muted); padding: .5rem; border-radius: 999px; font: inherit; font-weight: 700; cursor: pointer; }
.auth-tabs button.on { background: var(--brand); color: #fff; }

.chat { display: flex; flex-direction: column; gap: .6rem; max-height: 460px; overflow-y: auto; padding: .3rem; }
.chat .msg { max-width: 76%; padding: .55rem .8rem; border-radius: 12px; background: var(--surface-2); font-size: .88rem; }
.chat .msg.me { align-self: flex-end; background: linear-gradient(135deg, var(--brand), #4f46e5); }
.chat .msg .when { font-size: .68rem; color: var(--muted); margin-top: .2rem; }

.timeline { display: flex; flex-direction: column; gap: .7rem; }
.timeline .ev { display: flex; gap: .7rem; align-items: flex-start; }
.timeline .ev .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); margin-top: .45rem; flex: 0 0 auto; }

.kv { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: .4rem 1rem; font-size: .89rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

.switch { position: relative; display: inline-block; width: 42px; height: 23px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px; transition: .2s; }
.switch i::before { content: ""; position: absolute; width: 17px; height: 17px; left: 2px; top: 2px; background: var(--muted); border-radius: 50%; transition: .2s; }
.switch input:checked + i { background: rgba(99, 102, 241, .4); border-color: var(--brand); }
.switch input:checked + i::before { transform: translateX(19px); background: #fff; }

@media (max-width: 1100px) {
  .g4, .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; transform: translateX(-100%); transition: .2s; z-index: 60; }
  .sidebar.open { transform: none; }
  .g2, .g3, .g4, .g5, .form-grid { grid-template-columns: 1fr; }
  .site-nav { display: none; }
  .content { padding: 1rem; }
}

/* ------------------------------------------------------------ language picker */
.lang-select {
  appearance: none;
  background: var(--surface, #fff);
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 10px;
  padding: .32rem 1.6rem .32rem .6rem;
  font: inherit;
  font-size: .82rem;
  color: inherit;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 12px) 52%, calc(100% - 7px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.lang-select:focus-visible { outline: 2px solid var(--brand, #6366f1); outline-offset: 1px; }
