@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --sidebar-bg: #0e0e13;
  --sidebar-border: rgba(255,255,255,0.06);
  --sidebar-text: #8b8b99;
  --sidebar-text-hover: #ffffff;
  --sidebar-active-bg: rgba(255,255,255,0.08);
  --sidebar-active-text: #ffffff;
  --content-bg: #f4f4f8;
  --accent: #6366f1;
  --accent-hover: #4f52e0;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #1a1a2e;
  background: var(--content-bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Скроллбар ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo-mark {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.sidebar-logo-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.2px;
}

.sidebar-project {
  padding: 12px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-project-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #454558;
  margin-bottom: 6px;
}

.sidebar-project-name {
  font-size: 12px;
  color: #a0a0b8;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  padding: 6px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #454558;
  padding: 4px 8px;
  margin: 8px 0 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 7px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 400;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.05);
  color: var(--sidebar-text-hover);
}

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 500;
}

.sidebar-link svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-link.active svg,
.sidebar-link:hover svg {
  opacity: 1;
}

.sidebar-user {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 9px;
}

.sidebar-user-avatar {
  width: 28px;
  height: 28px;
  background: rgba(99,102,241,0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #a5a8f5;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 12px;
  font-weight: 500;
  color: #9090a8;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-logout {
  color: #454558;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 5px;
  display: flex;
  transition: color 0.12s;
}
.sidebar-user-logout:hover { color: #9090a8; }

/* ── Main content ───────────────────────────────────────── */
.main-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.main-header {
  background: var(--content-bg);
  padding: 20px 28px 0;
}

.main-header h1 {
  font-size: 20px;
  font-weight: 600;
  color: #0e0e1a;
  letter-spacing: -0.4px;
}

.main-body {
  flex: 1;
  padding: 20px 28px 40px;
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
}

.card:hover {
  box-shadow: var(--card-shadow-hover);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: #fff;
  color: #3d3d55;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.1), var(--card-shadow);
}
.btn-secondary:hover { background: #fafafa; color: #0e0e1a; }

.btn-ghost {
  background: transparent;
  color: #6b6b80;
}
.btn-ghost:hover { background: rgba(0,0,0,0.04); color: #0e0e1a; }

.btn-danger {
  background: transparent;
  color: #d1d1db;
}
.btn-danger:hover { color: #ef4444; }

/* ── Inputs ─────────────────────────────────────────────── */
.input {
  width: 100%;
  border: 1px solid #e5e5ed;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-family: inherit;
  color: #0e0e1a;
  background: #fff;
  transition: border-color 0.12s, box-shadow 0.12s;
  outline: none;
}
.input:hover { border-color: #c8c8d8; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
.input::placeholder { color: #b0b0c4; }

textarea.input { resize: vertical; }

select.input { cursor: pointer; }

/* ── Badges ─────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500; letter-spacing: 0.01em; }
.badge-company  { background: #eff6ff; color: #3b82f6; }
.badge-expert   { background: #f5f3ff; color: #7c3aed; }
.badge-service  { background: #fffbeb; color: #d97706; }
.badge-green    { background: #f0fdf4; color: #16a34a; }
.badge-gray     { background: #f4f4f8; color: #6b6b80; }

/* ── Tables ─────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 10px 16px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; color: #9090a8; border-bottom: 1px solid #f0f0f5; }
.table td { padding: 12px 16px; color: #2d2d42; border-bottom: 1px solid #f7f7fb; }
.table tbody tr:hover td { background: #fafafe; }
.table tbody tr:last-child td { border-bottom: none; }

/* ── Tabs ───────────────────────────────────────────────── */
.tab-bar { display: flex; gap: 2px; border-bottom: 1px solid #ebebf3; margin-bottom: 20px; }
.tab-btn { padding: 8px 14px; font-size: 13px; color: #8080a0; background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; transition: color 0.12s, border-color 0.12s; font-family: inherit; font-weight: 400; }
.tab-btn:hover { color: #3d3d55; }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }

/* ── Section headers ────────────────────────────────────── */
.section-label { font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.07em; color: #9090a8; margin-bottom: 8px; }

/* ── Dividers ───────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid #f0f0f5; margin: 0; }

/* ── Alerts ─────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ── Transitions ────────────────────────────────────────── */
a, button { transition: color 0.12s, background 0.12s, box-shadow 0.12s, border-color 0.12s, opacity 0.12s; }

/* ── Mobile ─────────────────────────────────────────────── */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: var(--sidebar-bg);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--sidebar-border);
}

.mobile-burger {
  background: rgba(255,255,255,0.06);
  border: none;
  border-radius: 7px;
  color: #9090a8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
}
.mobile-burger:hover { background: rgba(255,255,255,0.1); color: #fff; }

.mobile-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.2px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 49;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { display: block; }

@media (max-width: 767px) {
  .mobile-header { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }

  #app-layout {
    flex-direction: column;
    height: auto !important;
    overflow: visible !important;
  }

  .main-wrap {
    height: auto;
    overflow: visible;
  }

  .main-header { padding: 16px 16px 0; }
  .main-header h1 { font-size: 17px; }
  .main-body { padding: 14px 16px 40px; }

  /* Адаптивные сетки */
  .grid-stats { grid-template-columns: repeat(3, 1fr) !important; }
}

@media (max-width: 479px) {
  .main-body { padding: 12px 12px 40px; }
  .grid-stats { grid-template-columns: repeat(2, 1fr) !important; }
}

/* Competitors grid — адаптив */
@media (max-width: 1023px) {
  #competitors-grid { grid-template-columns: 1fr !important; }
}

/* Competitor detail form */
@media (max-width: 767px) {
  .max-w-4xl { max-width: 100% !important; }
}
