* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #111111;
  --muted: #777777;
  --border: #e5e5e5;
  --border-strong: #111111;
  --radius: 16px;
  --radius-sm: 10px;
}

body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; width: 100%; }
a { color: inherit; }
main { flex: 1; }

/* Header */
/* Header - добавь тень для визуального отделения */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* Гарантированный отступ для первого элемента в main */
main > .container:first-child,
main > *:first-child {
  margin-top: 24px;
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  gap: 20px;
}
.logo {
  display: flex; align-items: center; gap: 14px;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-img {
  width: 56px; height: 56px;
  object-fit: contain;
  border-radius: 12px;
  display: block;
}
.logo-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
  max-width: 220px;
}

.nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.nav > a {
  padding: 8px 14px; border-radius: 10px;
  text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: background 0.15s;
}
.nav > a:hover { background: #f2f2f2; }
.nav > a.active { background: var(--border-strong); color: #fff; }
.btn-accent { background: var(--border-strong) !important; color: #fff !important; }
.btn-accent:hover { background: #333 !important; }

.burger { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 18px; cursor: pointer; }

/* Profile dropdown */
.profile-dropdown { position: relative; }
.profile-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 5px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  font-family: inherit;
  color: var(--text);
}
.profile-btn:hover { background: #f5f5f5; border-color: var(--border-strong); }
.profile-btn-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--border-strong);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
}
.arrow { font-size: 10px; color: var(--muted); }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 180px;
  padding: 6px;
  display: none;
  z-index: 200;
}
.dropdown-menu.open { display: block; }
.dropdown-item {
  display: block;
  padding: 9px 12px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s;
  color: var(--text);
}
.dropdown-item:hover { background: #f5f5f5; }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Main - УВЕЛИЧЕН ОТСТУП ДО 64px */
main { padding: 64px 24px 60px; }

/* Avatar upload */
.avatar-upload {
  position: relative;
  cursor: pointer;
}
.avatar-upload input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.avatar-upload:hover::after {
  content: 'Изменить';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.7);
  color: #fff;
  text-align: center;
  padding: 6px;
  border-radius: 0 0 50% 50%;
  font-size: 12px;
}
.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

@media (max-width: 768px) {
  main { padding: 48px 24px 60px; }
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
}
.card-title { font-size: 20px; font-weight: 700; margin-bottom: 14px; }
.card-sub { color: var(--muted); margin-bottom: 20px; font-size: 14px; }

/* Hero */
.hero {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 56px 32px;
  text-align: center;
  margin-bottom: 24px;
}
.hero h1 { font-size: 36px; margin-bottom: 14px; letter-spacing: -0.5px; font-weight: 800; }
.hero p { font-size: 16px; color: var(--muted); max-width: 560px; margin: 0 auto 28px; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 11px 22px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--border-strong);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
  font-family: inherit;
}
.btn:hover { background: #333; }
.btn-secondary {
  background: #fff; color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #f5f5f5; }
.btn-danger { background: #fff; color: #c00; border-color: #fcc; }
.btn-danger:hover { background: #fff5f5; }
.btn-small { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; }

/* Forms */
.form { max-width: 440px; margin: 0 auto; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.15s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none; border-color: var(--border-strong);
}
.form-group textarea { min-height: 90px; resize: vertical; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Grid */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* Profile */
.profile-header {
  display: flex; gap: 28px; align-items: center;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.avatar {
  width: 100px; height: 100px;
  border-radius: 50%;
  background: var(--border-strong);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 700;
  flex-shrink: 0;
}
.profile-info h2 { font-size: 24px; margin-bottom: 4px; }
.profile-rank { font-weight: 600; margin-bottom: 10px; font-size: 14px; }
.profile-meta { color: var(--muted); font-size: 13px; }

/* Progress */
.progress-wrap { margin: 14px 0; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.progress {
  height: 6px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--border-strong);
  border-radius: 6px;
  transition: width 0.4s;
}

/* Stats */
.stat {
  text-align: center;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat-value { font-size: 28px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Badges */
.badge {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.badge-icon { 
  width: 24px; 
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.badge-icon svg { width: 100%; height: 100%; }
.badge.locked { opacity: 0.35; filter: grayscale(1); }

/* Items */
.item {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; justify-content: space-between; align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.item + .item { margin-top: 10px; }
.item-info h3 { font-size: 15px; margin-bottom: 3px; font-weight: 600; }
.item-info p { color: var(--muted); font-size: 13px; }
.item-meta {
  background: #f5f5f5;
  color: var(--text);
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 12px;
}

/* Ranks */
.rank-item {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 14px;
}
.rank-item.current { border-color: var(--border-strong); background: #fafafa; }
.rank-num {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: #f5f5f5;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rank-num svg { width: 24px; height: 24px; }
.rank-item.current .rank-num { background: var(--border-strong); color: #fff; }
.rank-item.current .rank-num svg { stroke: #fff; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid;
}
.alert-error { background: #fff5f5; color: #c00; border-color: #fcc; }

/* News */
.news-item {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.news-item + .news-item { margin-top: 12px; }
.news-date { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.news-title { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.news-text { font-size: 14px; color: #333; }

/* Portfolio image */
.portfolio-img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}
.portfolio-moderation {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
}
.mod-pending { background: #fffbea; color: #8a6d00; }
.mod-approved { background: #f0f0f0; color: #333; }
.mod-rejected { background: #fff5f5; color: #c00; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  padding: 10px 16px;
  background: none; border: none;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
  color: var(--muted);
  white-space: nowrap;
}
.tab.active { color: var(--text); border-bottom-color: var(--border-strong); }

/* People */
.person-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 14px;
}
.person-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--border-strong);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 28px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: auto;
}

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { display: none; }
.switch-slider {
  width: 38px; height: 22px;
  background: var(--border);
  border-radius: 22px;
  position: relative;
  transition: background 0.2s;
}
.switch-slider::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.switch input:checked + .switch-slider { background: var(--border-strong); }
.switch input:checked + .switch-slider::after { transform: translateX(16px); }

/* Icon helpers */
.icon-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.icon-inline svg {
  width: 16px;
  height: 16px;
}

/* Responsive */
@media (max-width: 768px) {
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: #fff; flex-direction: column; padding: 12px; border-bottom: 1px solid var(--border); align-items: stretch; }
  .nav.open { display: flex; }
  .burger { display: block; }
  .hero { padding: 36px 20px; }
  .hero h1 { font-size: 26px; }
  .profile-header { flex-direction: column; text-align: center; }
  .logo-img { width: 44px; height: 44px; }
  .logo-text { font-size: 12px; max-width: 160px; }
  .dropdown-menu { right: auto; left: 0; }
  .profile-dropdown { width: 100%; }
  .profile-btn { width: 100%; justify-content: flex-start; }
  main { padding: 32px 24px 60px; }
}